From 267b7fee8ba727b15f2388cd9e7c3a23ffe95b88 Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 22 Feb 2025 15:26:13 +0000 Subject: [PATCH 1/3] Adopt PHP attributes in test classes --- tests/InstallCommandTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/InstallCommandTest.php b/tests/InstallCommandTest.php index be22902..c1f3cdc 100644 --- a/tests/InstallCommandTest.php +++ b/tests/InstallCommandTest.php @@ -2,6 +2,7 @@ namespace Esign\InstallCommand\Tests; +use PHPUnit\Framework\Attributes\Test; use Esign\InstallCommand\Exceptions\CouldNotInstallNodePackagesException; use Esign\InstallCommand\Tests\Support\InstallCommand; use Illuminate\Support\Facades\File; @@ -9,7 +10,7 @@ class InstallCommandTest extends TestCase { - /** @test */ + #[Test] public function it_can_publish_files() { $this->artisan(InstallCommand::class); @@ -17,7 +18,7 @@ public function it_can_publish_files() $this->assertFileExists(app_path('Services/UserService.php')); } - /** @test */ + #[Test] public function it_can_append_after_the_search_value_in_a_file() { $this->artisan(InstallCommand::class); @@ -33,7 +34,7 @@ public function isAdmin(): bool )); } - /** @test */ + #[Test] public function it_can_install_composer_packages() { $this->artisan(InstallCommand::class); @@ -42,7 +43,7 @@ public function it_can_install_composer_packages() Process::assertRan('composer require --dev my/dev-composer-package'); } - /** @test */ + #[Test] public function it_can_throw_an_exception_when_no_package_json_file_is_present() { File::delete(base_path('package.json')); @@ -51,7 +52,7 @@ public function it_can_throw_an_exception_when_no_package_json_file_is_present() $command->expectsOutput("Could not find package.json file in the root of your project. Please create one using `npm init`"); } - /** @test */ + #[Test] public function it_can_install_node_packages() { $this->artisan(InstallCommand::class); From 9d2306a24e6ba852d98c38549f124a1c4246cd71 Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 22 Feb 2025 15:26:13 +0000 Subject: [PATCH 2/3] Add return types to test methods --- tests/InstallCommandTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/InstallCommandTest.php b/tests/InstallCommandTest.php index c1f3cdc..b4c7ca0 100644 --- a/tests/InstallCommandTest.php +++ b/tests/InstallCommandTest.php @@ -11,7 +11,7 @@ class InstallCommandTest extends TestCase { #[Test] - public function it_can_publish_files() + public function it_can_publish_files(): void { $this->artisan(InstallCommand::class); @@ -19,7 +19,7 @@ public function it_can_publish_files() } #[Test] - public function it_can_append_after_the_search_value_in_a_file() + public function it_can_append_after_the_search_value_in_a_file(): void { $this->artisan(InstallCommand::class); @@ -35,7 +35,7 @@ public function isAdmin(): bool } #[Test] - public function it_can_install_composer_packages() + public function it_can_install_composer_packages(): void { $this->artisan(InstallCommand::class); @@ -44,7 +44,7 @@ public function it_can_install_composer_packages() } #[Test] - public function it_can_throw_an_exception_when_no_package_json_file_is_present() + public function it_can_throw_an_exception_when_no_package_json_file_is_present(): void { File::delete(base_path('package.json')); $command = $this->artisan(InstallCommand::class); @@ -53,7 +53,7 @@ public function it_can_throw_an_exception_when_no_package_json_file_is_present() } #[Test] - public function it_can_install_node_packages() + public function it_can_install_node_packages(): void { $this->artisan(InstallCommand::class); From e576956dda8a25416254396d871cf2dbaa16a194 Mon Sep 17 00:00:00 2001 From: Shift Date: Sat, 22 Feb 2025 15:26:13 +0000 Subject: [PATCH 3/3] Define test classes as `final` --- tests/InstallCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/InstallCommandTest.php b/tests/InstallCommandTest.php index b4c7ca0..ec2c9b2 100644 --- a/tests/InstallCommandTest.php +++ b/tests/InstallCommandTest.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Process; -class InstallCommandTest extends TestCase +final class InstallCommandTest extends TestCase { #[Test] public function it_can_publish_files(): void