Skip to content

Commit

Permalink
Fixed public path handling and fixed other issues with the gh actions (
Browse files Browse the repository at this point in the history
…#97)

* Fixed public path handling and property placement of file

* Migrate phpunit configuration before executing the tests.

* Disable coverage.

* not all php versions use the newer phpunit version and do not need the migration.

* styleci-issues fixed.

* better fix after analyzing the root cause.
  • Loading branch information
thirsch authored May 11, 2024
1 parent 30e6027 commit 8e0c618
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/phpunit-l10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ jobs:
composer require "illuminate/support:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --no-progress
composer update --${{ matrix.dependency }} --prefer-dist --no-interaction --no-suggest --no-progress
- name: Migrate configuration file
run: vendor/bin/phpunit --migrate-configuration || true

- name: Execute tests
run: vendor/bin/phpunit
3 changes: 3 additions & 0 deletions .github/workflows/phpunit-l11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ jobs:
composer require "illuminate/support:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency }} --prefer-dist --no-interaction --no-suggest
- name: Migrate configuration file
run: vendor/bin/phpunit --migrate-configuration

- name: Execute tests
run: vendor/bin/phpunit
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<!--<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
Expand All @@ -21,7 +21,7 @@
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
</coverage>-->
<testsuites>
<testsuite name="Sri test suite">
<directory>tests</directory>
Expand Down
15 changes: 9 additions & 6 deletions tests/Components/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

class LinkTest extends TestCase
{
protected function getEnvironmentSetUp($app)
{
if (method_exists($app, 'usePublicPath')) {
$app->usePublicPath(dirname(__DIR__).'/files');
} else {
$app->instance('path.public', dirname(__DIR__).'/files');
}
}

protected function tearDown(): void
{
$this->artisan('view:clear');
Expand All @@ -20,8 +29,6 @@ public function it_renders_the_component()
'subresource-integrity.mix_sri_path' => './tests/files/mix-sri.json',
]);

$this->app->instance('path.public', dirname(__DIR__).'/files');

$view = View::file(dirname(__DIR__).'/files/link.blade.php', ['mix' => false, 'crossOrigin' => null])->render();
$expected = <<<'HTML'
<link href="http://localhost/css/app.css" integrity="this-hash-is-valid" crossorigin="anonymous" rel="stylesheet" />
Expand All @@ -40,8 +47,6 @@ public function it_uses_mix_when_the_mix_attribute_is_passed()
'subresource-integrity.mix_sri_path' => './tests/files/mix-sri.json',
]);

$this->app->instance('path.public', dirname(__DIR__).'/files');

$view = View::file(dirname(__DIR__).'/files/link.blade.php', ['mix' => true, 'crossOrigin' => null])->render();
$expected = <<<'HTML'
<link href="/css/app.css?id=some-random-string" integrity="this-hash-is-valid" crossorigin="anonymous" rel="stylesheet" />
Expand All @@ -60,8 +65,6 @@ public function it_uses_the_crossorigin_attribute_if_passed()
'subresource-integrity.mix_sri_path' => './tests/files/mix-sri.json',
]);

$this->app->instance('path.public', dirname(__DIR__).'/files');

$view = View::file(dirname(__DIR__).'/files/link.blade.php', ['mix' => false, 'crossOrigin' => 'test'])->render();
$expected = <<<'HTML'
<link href="http://localhost/css/app.css" integrity="this-hash-is-valid" crossorigin="test" rel="stylesheet" />
Expand Down
15 changes: 9 additions & 6 deletions tests/Components/ScriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

class ScriptTest extends TestCase
{
protected function getEnvironmentSetUp($app)
{
if (method_exists($app, 'usePublicPath')) {
$app->usePublicPath(dirname(__DIR__).'/files');
} else {
$app->instance('path.public', dirname(__DIR__).'/files');
}
}

protected function tearDown(): void
{
$this->artisan('view:clear');
Expand All @@ -20,8 +29,6 @@ public function it_renders_the_component()
'subresource-integrity.mix_sri_path' => './tests/files/mix-sri.json',
]);

$this->app->instance('path.public', dirname(__DIR__).'/files');

$view = View::file(dirname(__DIR__).'/files/script.blade.php', ['mix' => false, 'crossOrigin' => 'anonymous'])->render();
$expected = <<<'HTML'
<script src="http://localhost/js/app.js" integrity="this-hash-is-valid" crossorigin="anonymous" ></script>
Expand All @@ -40,8 +47,6 @@ public function it_uses_mix_when_the_mix_attribute_is_passed()
'subresource-integrity.mix_sri_path' => './tests/files/mix-sri.json',
]);

$this->app->instance('path.public', dirname(__DIR__).'/files');

$view = View::file(dirname(__DIR__).'/files/script.blade.php', ['mix' => true, 'crossOrigin' => 'anonymous'])->render();
$expected = <<<'HTML'
<script src="/js/app.js?id=some-random-string" integrity="this-hash-is-valid" crossorigin="anonymous" ></script>
Expand All @@ -60,8 +65,6 @@ public function it_uses_the_crossorigin_attribute_if_passed()
'subresource-integrity.mix_sri_path' => './tests/files/mix-sri.json',
]);

$this->app->instance('path.public', dirname(__DIR__).'/files');

$view = View::file(dirname(__DIR__).'/files/script.blade.php', ['mix' => false, 'crossOrigin' => 'test'])->render();
$expected = <<<'HTML'
<script src="http://localhost/js/app.js" integrity="this-hash-is-valid" crossorigin="test" ></script>
Expand Down

0 comments on commit 8e0c618

Please sign in to comment.