From 106ed2fca7bbebdb96719febf9ef90259b214783 Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 1 Mar 2025 20:43:18 +0000 Subject: [PATCH 01/13] Ignore PHPUnit cache folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e39e94f..0d83a6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ composer.lock phpunit.xml vendor -/.idea \ No newline at end of file +/.idea +/.phpunit.cache \ No newline at end of file From f323bc7b31cbac3ac7de13fc3bd041dfca2b6c9d Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 1 Mar 2025 20:43:18 +0000 Subject: [PATCH 02/13] Adopt PHP attributes in test classes --- tests/HTMLMinTest.php | 5 ++--- tests/Minifiers/BladeMinifierTest.php | 9 +++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/HTMLMinTest.php b/tests/HTMLMinTest.php index 3740eb6..1a7ac2f 100644 --- a/tests/HTMLMinTest.php +++ b/tests/HTMLMinTest.php @@ -12,6 +12,7 @@ namespace HTMLMin\Tests\HTMLMin; +use PHPUnit\Framework\Attributes\DataProvider; use GrahamCampbell\TestBench\AbstractTestCase as AbstractTestBenchTestCase; use HTMLMin\HTMLMin\HTMLMin; use HTMLMin\HTMLMin\Minifiers\BladeMinifier; @@ -37,9 +38,7 @@ public function methodProvider() ]; } - /** - * @dataProvider methodProvider - */ + #[DataProvider('methodProvider')] public function testMethods($method, $class) { $htmlmin = $this->getHTMLMin(); diff --git a/tests/Minifiers/BladeMinifierTest.php b/tests/Minifiers/BladeMinifierTest.php index 936a5a8..b56808a 100644 --- a/tests/Minifiers/BladeMinifierTest.php +++ b/tests/Minifiers/BladeMinifierTest.php @@ -12,6 +12,7 @@ namespace HTMLMin\Tests\HTMLMin\Minifiers; +use PHPUnit\Framework\Attributes\DataProvider; use GrahamCampbell\TestBench\AbstractTestCase; use HTMLMin\HTMLMin\Minifiers\BladeMinifier; @@ -44,9 +45,7 @@ public function tagProvider() ]; } - /** - * @dataProvider tagProvider - */ + #[DataProvider('tagProvider')] public function testRenderHtmlDisabled($tag) { $blade = $this->getBladeMinifier(); @@ -65,9 +64,7 @@ public function testRenderCommentDisabled() $this->assertSame('test getBladeMinifier(true); From 332d56fca24589448db53ce188fd8ab054fa790a Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 1 Mar 2025 20:43:18 +0000 Subject: [PATCH 03/13] Declare data providers as `static` --- tests/HTMLMinTest.php | 2 +- tests/Minifiers/BladeMinifierTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/HTMLMinTest.php b/tests/HTMLMinTest.php index 1a7ac2f..e77386a 100644 --- a/tests/HTMLMinTest.php +++ b/tests/HTMLMinTest.php @@ -28,7 +28,7 @@ */ class HTMLMinTest extends AbstractTestBenchTestCase { - public function methodProvider() + public static function methodProvider() { return [ ['blade', 'getBladeMinifier'], diff --git a/tests/Minifiers/BladeMinifierTest.php b/tests/Minifiers/BladeMinifierTest.php index b56808a..ad7bfea 100644 --- a/tests/Minifiers/BladeMinifierTest.php +++ b/tests/Minifiers/BladeMinifierTest.php @@ -36,7 +36,7 @@ public function testRenderEnabled() $this->assertSame('test
', $return); } - public function tagProvider() + public static function tagProvider() { return [ ['textarea'], From 8c4f3fbc5cf2a94b0193442520708174352b6876 Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 1 Mar 2025 20:43:19 +0000 Subject: [PATCH 04/13] Add return types to test methods --- tests/Compilers/MinifyCompilerTest.php | 6 +++--- tests/Functional/BladeEnabledTest.php | 2 +- tests/Functional/ComponentsTest.php | 2 +- tests/Functional/DirectivesTest.php | 2 +- tests/Functional/MiddlewareTest.php | 6 +++--- tests/Functional/Provider/TestDirectivesProvider.php | 2 +- tests/Functional/SkipMinificationTest.php | 4 ++-- tests/HTMLMinTest.php | 4 ++-- tests/Minifiers/BladeMinifierTest.php | 10 +++++----- tests/Minifiers/CssMinifierTest.php | 2 +- tests/Minifiers/HtmlMinifierTest.php | 4 ++-- tests/Minifiers/JsMinifierTest.php | 2 +- tests/ServiceProviderTest.php | 12 ++++++------ 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/Compilers/MinifyCompilerTest.php b/tests/Compilers/MinifyCompilerTest.php index afd9a99..2ad0348 100644 --- a/tests/Compilers/MinifyCompilerTest.php +++ b/tests/Compilers/MinifyCompilerTest.php @@ -25,7 +25,7 @@ */ class MinifyCompilerTest extends AbstractTestCase { - public function testMinify() + public function testMinify(): void { $compiler = $this->getCompiler(); @@ -37,7 +37,7 @@ public function testMinify() $this->assertSame('abc', $return); } - public function testMinifyIgnored() + public function testMinifyIgnored(): void { $blade = Mockery::mock(BladeMinifier::class); $files = Mockery::mock(Filesystem::class); @@ -57,7 +57,7 @@ public function testMinifyIgnored() $this->assertSame($html, $return); } - public function testCompilers() + public function testCompilers(): void { $compiler = $this->getCompiler(); diff --git a/tests/Functional/BladeEnabledTest.php b/tests/Functional/BladeEnabledTest.php index b80cc25..2db8243 100644 --- a/tests/Functional/BladeEnabledTest.php +++ b/tests/Functional/BladeEnabledTest.php @@ -35,7 +35,7 @@ protected function getEnvironmentSetUp($app) $app->config->set('htmlmin.blade', true); } - public function testNewSetup() + public function testNewSetup(): void { $this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs')); diff --git a/tests/Functional/ComponentsTest.php b/tests/Functional/ComponentsTest.php index 2313fc3..9819045 100644 --- a/tests/Functional/ComponentsTest.php +++ b/tests/Functional/ComponentsTest.php @@ -19,7 +19,7 @@ protected function getRequiredServiceProviders($app) return [TestComponentsProvider::class]; } - public function testUseComponents() + public function testUseComponents(): void { if (version_compare($this->app->version(), '7.0', '<')) { $this->markTestSkipped('Class components were released in Laravel version 7.0.0'); diff --git a/tests/Functional/DirectivesTest.php b/tests/Functional/DirectivesTest.php index 45f3369..b933151 100644 --- a/tests/Functional/DirectivesTest.php +++ b/tests/Functional/DirectivesTest.php @@ -20,7 +20,7 @@ protected function getRequiredServiceProviders($app) return [TestDirectivesProvider::class]; } - public function testUseDirectives() + public function testUseDirectives(): void { /** @var MinifyCompiler $minifyCompiler */ $minifyCompiler = $this->app->make('view') diff --git a/tests/Functional/MiddlewareTest.php b/tests/Functional/MiddlewareTest.php index 1690e37..5d179a7 100644 --- a/tests/Functional/MiddlewareTest.php +++ b/tests/Functional/MiddlewareTest.php @@ -38,7 +38,7 @@ protected function getEnvironmentSetUp($app) $app->config->set('htmlmin.live', true); } - public function testNewSetup() + public function testNewSetup(): void { $this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs')); @@ -53,7 +53,7 @@ public function testNewSetup() $this->assertSameIgnoreLineEndings($expected, $actual); } - public function testRedirect() + public function testRedirect(): void { $this->app->router->get('htmlmin-test-route', ['middleware' => MinifyMiddleware::class, function () { return Redirect::to('foo'); @@ -64,7 +64,7 @@ public function testRedirect() $this->assertSame($this->app->url->to('foo'), $response->headers->get('Location')); } - public function testJson() + public function testJson(): void { $this->app->router->get('htmlmin-test-route', ['middleware' => MinifyMiddleware::class, function () { return Response::json(['foo' => 'bar', ['baz']], 200, [], JSON_PRETTY_PRINT); diff --git a/tests/Functional/Provider/TestDirectivesProvider.php b/tests/Functional/Provider/TestDirectivesProvider.php index e9b4896..13053a6 100644 --- a/tests/Functional/Provider/TestDirectivesProvider.php +++ b/tests/Functional/Provider/TestDirectivesProvider.php @@ -7,7 +7,7 @@ class TestDirectivesProvider extends ServiceProvider { - public static function testDirective() + public static function testDirective(): void { return 'test content'; } diff --git a/tests/Functional/SkipMinificationTest.php b/tests/Functional/SkipMinificationTest.php index 74a7e41..1f6ab51 100644 --- a/tests/Functional/SkipMinificationTest.php +++ b/tests/Functional/SkipMinificationTest.php @@ -37,7 +37,7 @@ protected function getEnvironmentSetUp($app) $app->config->set('htmlmin.blade', true); } - public function testNewSkipHMTL() + public function testNewSkipHMTL(): void { $this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs')); @@ -48,7 +48,7 @@ public function testNewSkipHMTL() $this->assertSameIgnoreLineEndings($expected, $actual); } - public function testMarkDown() + public function testMarkDown(): void { $this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs')); diff --git a/tests/HTMLMinTest.php b/tests/HTMLMinTest.php index e77386a..f7f5b26 100644 --- a/tests/HTMLMinTest.php +++ b/tests/HTMLMinTest.php @@ -28,7 +28,7 @@ */ class HTMLMinTest extends AbstractTestBenchTestCase { - public static function methodProvider() + public static function methodProvider(): array { return [ ['blade', 'getBladeMinifier'], @@ -39,7 +39,7 @@ public static function methodProvider() } #[DataProvider('methodProvider')] - public function testMethods($method, $class) + public function testMethods($method, $class): void { $htmlmin = $this->getHTMLMin(); diff --git a/tests/Minifiers/BladeMinifierTest.php b/tests/Minifiers/BladeMinifierTest.php index ad7bfea..dd391d6 100644 --- a/tests/Minifiers/BladeMinifierTest.php +++ b/tests/Minifiers/BladeMinifierTest.php @@ -23,7 +23,7 @@ */ class BladeMinifierTest extends AbstractTestCase { - public function testRenderEnabled() + public function testRenderEnabled(): void { $blade = $this->getBladeMinifier(); @@ -36,7 +36,7 @@ public function testRenderEnabled() $this->assertSame('test
', $return); } - public static function tagProvider() + public static function tagProvider(): array { return [ ['textarea'], @@ -46,7 +46,7 @@ public static function tagProvider() } #[DataProvider('tagProvider')] - public function testRenderHtmlDisabled($tag) + public function testRenderHtmlDisabled($tag): void { $blade = $this->getBladeMinifier(); @@ -55,7 +55,7 @@ public function testRenderHtmlDisabled($tag) $this->assertSame("test <$tag>", $return); } - public function testRenderCommentDisabled() + public function testRenderCommentDisabled(): void { $blade = $this->getBladeMinifier(); @@ -65,7 +65,7 @@ public function testRenderCommentDisabled() } #[DataProvider('tagProvider')] - public function testRenderForced($tag) + public function testRenderForced($tag): void { $blade = $this->getBladeMinifier(true); diff --git a/tests/Minifiers/CssMinifierTest.php b/tests/Minifiers/CssMinifierTest.php index eb3010b..54ad51c 100644 --- a/tests/Minifiers/CssMinifierTest.php +++ b/tests/Minifiers/CssMinifierTest.php @@ -22,7 +22,7 @@ */ class CssMinifierTest extends AbstractTestCase { - public function testRender() + public function testRender(): void { $css = $this->getCssMinifier(); diff --git a/tests/Minifiers/HtmlMinifierTest.php b/tests/Minifiers/HtmlMinifierTest.php index 99fc9e4..7afaaa8 100644 --- a/tests/Minifiers/HtmlMinifierTest.php +++ b/tests/Minifiers/HtmlMinifierTest.php @@ -25,7 +25,7 @@ */ class HtmlMinifierTest extends AbstractTestCase { - public function testRenderQuick() + public function testRenderQuick(): void { $html = $this->getHtmlMinifier(); @@ -34,7 +34,7 @@ public function testRenderQuick() $this->assertSame('test', $return); } - public function testRenderFull() + public function testRenderFull(): void { $html = $this->getHtmlMinifier(); $text = 'test'; diff --git a/tests/Minifiers/JsMinifierTest.php b/tests/Minifiers/JsMinifierTest.php index 6b77787..536d9ac 100644 --- a/tests/Minifiers/JsMinifierTest.php +++ b/tests/Minifiers/JsMinifierTest.php @@ -22,7 +22,7 @@ */ class JsMinifierTest extends AbstractTestCase { - public function testRender() + public function testRender(): void { $js = $this->getJsMinifier(); diff --git a/tests/ServiceProviderTest.php b/tests/ServiceProviderTest.php index 8af4817..61a35f1 100644 --- a/tests/ServiceProviderTest.php +++ b/tests/ServiceProviderTest.php @@ -29,32 +29,32 @@ class ServiceProviderTest extends AbstractTestCase { use ServiceProviderTrait; - public function testCssMinifierIsInjectable() + public function testCssMinifierIsInjectable(): void { $this->assertIsInjectable(CssMinifier::class); } - public function testJsMinifierIsInjectable() + public function testJsMinifierIsInjectable(): void { $this->assertIsInjectable(JsMinifier::class); } - public function testHtmlMinifierIsInjectable() + public function testHtmlMinifierIsInjectable(): void { $this->assertIsInjectable(HtmlMinifier::class); } - public function testBladeMinifierIsInjectable() + public function testBladeMinifierIsInjectable(): void { $this->assertIsInjectable(BladeMinifier::class); } - public function testCompilerIsInjectable() + public function testCompilerIsInjectable(): void { $this->assertIsInjectable(MinifyCompiler::class); } - public function testHTMLMinIsInjectable() + public function testHTMLMinIsInjectable(): void { $this->assertIsInjectable(HTMLMin::class); } From 5d68f2f2c7e4a7c0948bc3704fa374648216e626 Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 1 Mar 2025 20:43:19 +0000 Subject: [PATCH 05/13] Define test classes as `final` --- tests/Compilers/MinifyCompilerTest.php | 2 +- tests/Functional/BladeEnabledTest.php | 2 +- tests/Functional/ComponentsTest.php | 2 +- tests/Functional/DirectivesTest.php | 2 +- tests/Functional/MiddlewareTest.php | 2 +- tests/Functional/Provider/TestDirectivesProvider.php | 2 +- tests/Functional/SkipMinificationTest.php | 2 +- tests/HTMLMinTest.php | 2 +- tests/Minifiers/BladeMinifierTest.php | 2 +- tests/Minifiers/CssMinifierTest.php | 2 +- tests/Minifiers/HtmlMinifierTest.php | 2 +- tests/Minifiers/JsMinifierTest.php | 2 +- tests/ServiceProviderTest.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/Compilers/MinifyCompilerTest.php b/tests/Compilers/MinifyCompilerTest.php index 2ad0348..420a6fc 100644 --- a/tests/Compilers/MinifyCompilerTest.php +++ b/tests/Compilers/MinifyCompilerTest.php @@ -23,7 +23,7 @@ * * @author Graham Campbell */ -class MinifyCompilerTest extends AbstractTestCase +final class MinifyCompilerTest extends AbstractTestCase { public function testMinify(): void { diff --git a/tests/Functional/BladeEnabledTest.php b/tests/Functional/BladeEnabledTest.php index 2db8243..2a281b8 100644 --- a/tests/Functional/BladeEnabledTest.php +++ b/tests/Functional/BladeEnabledTest.php @@ -19,7 +19,7 @@ * * @author Graham Campbell */ -class BladeEnabledTest extends AbstractFunctionalTestCase +final class BladeEnabledTest extends AbstractFunctionalTestCase { /** * Setup the application environment. diff --git a/tests/Functional/ComponentsTest.php b/tests/Functional/ComponentsTest.php index 9819045..ad73360 100644 --- a/tests/Functional/ComponentsTest.php +++ b/tests/Functional/ComponentsTest.php @@ -5,7 +5,7 @@ use HTMLMin\HTMLMin\Compilers\MinifyCompiler; use HTMLMin\Tests\HTMLMin\Functional\Provider\TestComponentsProvider; -class ComponentsTest extends AbstractFunctionalTestCase +final class ComponentsTest extends AbstractFunctionalTestCase { /** * Get the required service providers. diff --git a/tests/Functional/DirectivesTest.php b/tests/Functional/DirectivesTest.php index b933151..8358c69 100644 --- a/tests/Functional/DirectivesTest.php +++ b/tests/Functional/DirectivesTest.php @@ -6,7 +6,7 @@ use HTMLMin\Tests\HTMLMin\Functional\Provider\TestDirectivesProvider; use HTMLMin\Tests\HTMLMin\Mock\MinifyCompilerMock; -class DirectivesTest extends AbstractFunctionalTestCase +final class DirectivesTest extends AbstractFunctionalTestCase { /** * Get the required service providers. diff --git a/tests/Functional/MiddlewareTest.php b/tests/Functional/MiddlewareTest.php index 5d179a7..dc97aa8 100644 --- a/tests/Functional/MiddlewareTest.php +++ b/tests/Functional/MiddlewareTest.php @@ -22,7 +22,7 @@ * * @author Graham Campbell */ -class MiddlewareTest extends AbstractFunctionalTestCase +final class MiddlewareTest extends AbstractFunctionalTestCase { /** * Setup the application environment. diff --git a/tests/Functional/Provider/TestDirectivesProvider.php b/tests/Functional/Provider/TestDirectivesProvider.php index 13053a6..94cfddd 100644 --- a/tests/Functional/Provider/TestDirectivesProvider.php +++ b/tests/Functional/Provider/TestDirectivesProvider.php @@ -5,7 +5,7 @@ use Illuminate\Support\ServiceProvider; use Illuminate\View\Compilers\BladeCompiler; -class TestDirectivesProvider extends ServiceProvider +final class TestDirectivesProvider extends ServiceProvider { public static function testDirective(): void { diff --git a/tests/Functional/SkipMinificationTest.php b/tests/Functional/SkipMinificationTest.php index 1f6ab51..9827b82 100644 --- a/tests/Functional/SkipMinificationTest.php +++ b/tests/Functional/SkipMinificationTest.php @@ -19,7 +19,7 @@ * * @author Graham Campbell */ -class SkipMinificationTest extends AbstractFunctionalTestCase +final class SkipMinificationTest extends AbstractFunctionalTestCase { /** * Setup the application environment. diff --git a/tests/HTMLMinTest.php b/tests/HTMLMinTest.php index f7f5b26..683d4bc 100644 --- a/tests/HTMLMinTest.php +++ b/tests/HTMLMinTest.php @@ -26,7 +26,7 @@ * * @author Graham Campbell */ -class HTMLMinTest extends AbstractTestBenchTestCase +final class HTMLMinTest extends AbstractTestBenchTestCase { public static function methodProvider(): array { diff --git a/tests/Minifiers/BladeMinifierTest.php b/tests/Minifiers/BladeMinifierTest.php index dd391d6..c7d0b56 100644 --- a/tests/Minifiers/BladeMinifierTest.php +++ b/tests/Minifiers/BladeMinifierTest.php @@ -21,7 +21,7 @@ * * @author Graham Campbell */ -class BladeMinifierTest extends AbstractTestCase +final class BladeMinifierTest extends AbstractTestCase { public function testRenderEnabled(): void { diff --git a/tests/Minifiers/CssMinifierTest.php b/tests/Minifiers/CssMinifierTest.php index 54ad51c..9316bd2 100644 --- a/tests/Minifiers/CssMinifierTest.php +++ b/tests/Minifiers/CssMinifierTest.php @@ -20,7 +20,7 @@ * * @author Graham Campbell */ -class CssMinifierTest extends AbstractTestCase +final class CssMinifierTest extends AbstractTestCase { public function testRender(): void { diff --git a/tests/Minifiers/HtmlMinifierTest.php b/tests/Minifiers/HtmlMinifierTest.php index 7afaaa8..89ee080 100644 --- a/tests/Minifiers/HtmlMinifierTest.php +++ b/tests/Minifiers/HtmlMinifierTest.php @@ -23,7 +23,7 @@ * * @author Graham Campbell */ -class HtmlMinifierTest extends AbstractTestCase +final class HtmlMinifierTest extends AbstractTestCase { public function testRenderQuick(): void { diff --git a/tests/Minifiers/JsMinifierTest.php b/tests/Minifiers/JsMinifierTest.php index 536d9ac..57f98d5 100644 --- a/tests/Minifiers/JsMinifierTest.php +++ b/tests/Minifiers/JsMinifierTest.php @@ -20,7 +20,7 @@ * * @author Graham Campbell */ -class JsMinifierTest extends AbstractTestCase +final class JsMinifierTest extends AbstractTestCase { public function testRender(): void { diff --git a/tests/ServiceProviderTest.php b/tests/ServiceProviderTest.php index 61a35f1..b4d3c6f 100644 --- a/tests/ServiceProviderTest.php +++ b/tests/ServiceProviderTest.php @@ -25,7 +25,7 @@ * * @author Graham Campbell */ -class ServiceProviderTest extends AbstractTestCase +final class ServiceProviderTest extends AbstractTestCase { use ServiceProviderTrait; From cc1ca8a77d278847efd4c451124dbecb529de942 Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 15:45:39 -0500 Subject: [PATCH 06/13] Fix GHA workflow not failing --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8b94bbe..e4cec8a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,4 +33,3 @@ jobs: env: PHP_VERSION: ${{ matrix.php-versions }} run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml - continue-on-error: true From f2cc7f5d5230ed11862e78c58fef19ac930da905 Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 15:46:30 -0500 Subject: [PATCH 07/13] Run on push but not PRs --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e4cec8a..d62b4a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,5 @@ name: HTMLMinTests -on: [push, pull_request] +on: [push] jobs: htmlmin: name: PHP ${{ matrix.php-versions }} From 20d29982a16538133e5bf6b3dad10d270c61a32f Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 15:47:46 -0500 Subject: [PATCH 08/13] Fix syntax issue --- tests/AbstractTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index cd75a82..a09fc7a 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -29,7 +29,7 @@ abstract class AbstractTestCase extends AbstractPackageTestCase * * @return string */ - protected function getServiceProviderClass() + protected static function getServiceProviderClass() { return HTMLMinServiceProvider::class; } From 304c1124bdc1522f2757af1ab96e05b7f8eb381c Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 15:48:53 -0500 Subject: [PATCH 09/13] Fix syntax issue --- tests/AbstractTestCase.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index a09fc7a..d9966a2 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -22,14 +22,7 @@ */ abstract class AbstractTestCase extends AbstractPackageTestCase { - /** - * Get the service provider class. - * - * @param \Illuminate\Contracts\Foundation\Application $app - * - * @return string - */ - protected static function getServiceProviderClass() + protected static function getServiceProviderClass(): string { return HTMLMinServiceProvider::class; } From 1cc0e5065d36ab6987123c17d5331635f18060ad Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 15:50:50 -0500 Subject: [PATCH 10/13] Fix syntax issue --- tests/Facades/HTMLMinTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Facades/HTMLMinTest.php b/tests/Facades/HTMLMinTest.php index 71c7672..ebc8a2c 100644 --- a/tests/Facades/HTMLMinTest.php +++ b/tests/Facades/HTMLMinTest.php @@ -31,7 +31,7 @@ class HTMLMinTest extends AbstractTestCase * * @return string */ - protected function getFacadeAccessor() + protected static function getFacadeAccessor() { return 'htmlmin'; } From b842aba3852139f84dfe7079eb810c90a78e0484 Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 15:51:38 -0500 Subject: [PATCH 11/13] Fix syntax issue --- tests/Facades/HTMLMinTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Facades/HTMLMinTest.php b/tests/Facades/HTMLMinTest.php index ebc8a2c..f572d17 100644 --- a/tests/Facades/HTMLMinTest.php +++ b/tests/Facades/HTMLMinTest.php @@ -31,7 +31,7 @@ class HTMLMinTest extends AbstractTestCase * * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'htmlmin'; } From 1213872313522a2d9c8a2ce5178f87cb19d4381f Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 16:08:56 -0500 Subject: [PATCH 12/13] Migrate PHPUnit configuration --- phpunit.xml.dist | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bd51815..57c3b36 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,30 +1,13 @@ - - - - ./tests - - - - - ./src - - + + + + ./tests + + + + + ./src + + From 125658c0c703dafea2316ad78c277186e7f6ce71 Mon Sep 17 00:00:00 2001 From: Kristaps Berzinch Date: Sat, 1 Mar 2025 16:09:05 -0500 Subject: [PATCH 13/13] Fix tests --- src/HTMLMinServiceProvider.php | 2 +- tests/Facades/HTMLMinTest.php | 10 ++-------- tests/Functional/BladeEnabledTest.php | 4 +--- tests/Functional/ComponentsTest.php | 4 +--- tests/Functional/DirectivesTest.php | 4 +--- tests/Functional/MiddlewareTest.php | 4 +--- tests/Functional/Provider/TestDirectivesProvider.php | 1 - tests/Functional/SkipMinificationTest.php | 4 +--- 8 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/HTMLMinServiceProvider.php b/src/HTMLMinServiceProvider.php index 7eed413..5aa38a1 100644 --- a/src/HTMLMinServiceProvider.php +++ b/src/HTMLMinServiceProvider.php @@ -184,7 +184,7 @@ protected function registerMinifyCompiler() $storagePath = $app->config->get('view.compiled'); $ignoredPaths = $app->config->get('htmlmin.ignore', []); - return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $this->previousCompiler, $this->previousCompiler->getCustomDirectives()); + return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $this->previousCompiler, $this->previousCompiler?->getCustomDirectives() ?? []); }); $this->app->alias('htmlmin.compiler', MinifyCompiler::class); diff --git a/tests/Facades/HTMLMinTest.php b/tests/Facades/HTMLMinTest.php index f572d17..32fce2c 100644 --- a/tests/Facades/HTMLMinTest.php +++ b/tests/Facades/HTMLMinTest.php @@ -28,8 +28,6 @@ class HTMLMinTest extends AbstractTestCase /** * Get the facade accessor. - * - * @return string */ protected static function getFacadeAccessor(): string { @@ -38,20 +36,16 @@ protected static function getFacadeAccessor(): string /** * Get the facade class. - * - * @return string */ - protected function getFacadeClass() + protected static function getFacadeClass(): string { return Facade::class; } /** * Get the facade root. - * - * @return string */ - protected function getFacadeRoot() + protected static function getFacadeRoot(): string { return HTMLMin::class; } diff --git a/tests/Functional/BladeEnabledTest.php b/tests/Functional/BladeEnabledTest.php index 2a281b8..bd521c0 100644 --- a/tests/Functional/BladeEnabledTest.php +++ b/tests/Functional/BladeEnabledTest.php @@ -25,10 +25,8 @@ final class BladeEnabledTest extends AbstractFunctionalTestCase * Setup the application environment. * * @param \Illuminate\Contracts\Foundation\Application $app - * - * @return void */ - protected function getEnvironmentSetUp($app) + protected function getEnvironmentSetUp($app): void { parent::getEnvironmentSetUp($app); diff --git a/tests/Functional/ComponentsTest.php b/tests/Functional/ComponentsTest.php index ad73360..2c1e42e 100644 --- a/tests/Functional/ComponentsTest.php +++ b/tests/Functional/ComponentsTest.php @@ -10,11 +10,9 @@ final class ComponentsTest extends AbstractFunctionalTestCase /** * Get the required service providers. * - * @param \Illuminate\Contracts\Foundation\Application $app - * * @return string[] */ - protected function getRequiredServiceProviders($app) + protected static function getRequiredServiceProviders(): array { return [TestComponentsProvider::class]; } diff --git a/tests/Functional/DirectivesTest.php b/tests/Functional/DirectivesTest.php index 8358c69..2432d04 100644 --- a/tests/Functional/DirectivesTest.php +++ b/tests/Functional/DirectivesTest.php @@ -11,11 +11,9 @@ final class DirectivesTest extends AbstractFunctionalTestCase /** * Get the required service providers. * - * @param \Illuminate\Contracts\Foundation\Application $app - * * @return string[] */ - protected function getRequiredServiceProviders($app) + protected static function getRequiredServiceProviders(): array { return [TestDirectivesProvider::class]; } diff --git a/tests/Functional/MiddlewareTest.php b/tests/Functional/MiddlewareTest.php index dc97aa8..8141315 100644 --- a/tests/Functional/MiddlewareTest.php +++ b/tests/Functional/MiddlewareTest.php @@ -28,10 +28,8 @@ final class MiddlewareTest extends AbstractFunctionalTestCase * Setup the application environment. * * @param \Illuminate\Contracts\Foundation\Application $app - * - * @return void */ - protected function getEnvironmentSetUp($app) + protected function getEnvironmentSetUp($app): void { parent::getEnvironmentSetUp($app); diff --git a/tests/Functional/Provider/TestDirectivesProvider.php b/tests/Functional/Provider/TestDirectivesProvider.php index 94cfddd..cb8f05f 100644 --- a/tests/Functional/Provider/TestDirectivesProvider.php +++ b/tests/Functional/Provider/TestDirectivesProvider.php @@ -9,7 +9,6 @@ final class TestDirectivesProvider extends ServiceProvider { public static function testDirective(): void { - return 'test content'; } public function register() diff --git a/tests/Functional/SkipMinificationTest.php b/tests/Functional/SkipMinificationTest.php index 9827b82..a41f9d7 100644 --- a/tests/Functional/SkipMinificationTest.php +++ b/tests/Functional/SkipMinificationTest.php @@ -27,10 +27,8 @@ final class SkipMinificationTest extends AbstractFunctionalTestCase * Ensure that blade is on. * * @param \Illuminate\Contracts\Foundation\Application $app - * - * @return void */ - protected function getEnvironmentSetUp($app) + protected function getEnvironmentSetUp($app): void { parent::getEnvironmentSetUp($app);