diff --git a/composer.json b/composer.json index 58c1d18..7cf1430 100644 --- a/composer.json +++ b/composer.json @@ -29,9 +29,9 @@ "laravel/tinker": "dev-develop", "laravel/sail": "^1.26.2", "laravel/sanctum": "^4.0.0", - "nunomaduro/larastan": "^3.0.0", + "larastan/larastan": "^2.8.0", "orchestra/testbench-core": "^9.0.0", - "pestphp/pest": "^3.0.0", + "pestphp/pest": "^2.30.0 || ^3.0.0", "sebastian/environment": "^7.0.0" }, "autoload-dev": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8ee1e68..dbcf214 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,5 @@ includes: - - ./vendor/nunomaduro/larastan/extension.neon + - ./vendor/larastan/larastan/extension.neon parameters: level: max paths: diff --git a/tests/LaravelApp/bootstrap/app.php b/tests/LaravelApp/bootstrap/app.php index 6bec9a4..dcc68e5 100644 --- a/tests/LaravelApp/bootstrap/app.php +++ b/tests/LaravelApp/bootstrap/app.php @@ -15,7 +15,7 @@ | */ -return Application::configure() +return Application::configure(dirname(__DIR__)) ->withProviders() ->withRouting( web: __DIR__.'/../routes/web.php', diff --git a/tests/LaravelApp/tests/CreatesApplication.php b/tests/LaravelApp/tests/CreatesApplication.php deleted file mode 100644 index 0cd56d0..0000000 --- a/tests/LaravelApp/tests/CreatesApplication.php +++ /dev/null @@ -1,21 +0,0 @@ -make(Kernel::class)->bootstrap(); - - return $app; - } -} diff --git a/tests/LaravelApp/tests/Feature/CoverageTest.php b/tests/LaravelApp/tests/Feature/CoverageTest.php index 38053b1..b31be14 100644 --- a/tests/LaravelApp/tests/Feature/CoverageTest.php +++ b/tests/LaravelApp/tests/Feature/CoverageTest.php @@ -4,11 +4,10 @@ namespace Tests\Feature; +use PHPUnit\Framework\Attributes\Group; use Tests\TestCase; -/** - * @group coverage - */ +#[Group('coverage')] class CoverageTest extends TestCase { public function testExample() diff --git a/tests/LaravelApp/tests/Feature/EnvironmentCustomVariablesTest.php b/tests/LaravelApp/tests/Feature/EnvironmentCustomVariablesTest.php index 89cdb3b..c2c22f5 100644 --- a/tests/LaravelApp/tests/Feature/EnvironmentCustomVariablesTest.php +++ b/tests/LaravelApp/tests/Feature/EnvironmentCustomVariablesTest.php @@ -4,16 +4,13 @@ namespace Tests\Feature; +use PHPUnit\Framework\Attributes\Group; use Tests\TestCase; -/** - * @group environmentCustomVariables - */ +#[Group('environmentCustomVariables')] class EnvironmentCustomVariablesTest extends TestCase { - /** - * @group environmentNoCVPhpunit - */ + #[Group('environmentNoCVPhpunit')] public function testEnvironmentNoCustomVariablesPhpunit() { $this->assertEquals(null, env('LARAVEL_PARALLEL_TESTING')); @@ -23,9 +20,7 @@ public function testEnvironmentNoCustomVariablesPhpunit() $this->assertEquals(null, env('CUSTOM_ENV_VARIABLE_FOR_PARALLEL')); } - /** - * @group environmentNoCVParallel - */ + #[Group('environmentNoCVParallel')] public function testEnvironmentNoCustomVariablesParallel() { $this->assertEquals(1, env('LARAVEL_PARALLEL_TESTING')); @@ -35,9 +30,7 @@ public function testEnvironmentNoCustomVariablesParallel() $this->assertEquals(null, env('CUSTOM_ENV_VARIABLE_FOR_PARALLEL')); } - /** - * @group environmentNoCVParallelRecreate - */ + #[Group('environmentNoCVParallelRecreate')] public function testEnvironmentNoCustomVariablesParallelWithRecreate() { $this->assertEquals(1, env('LARAVEL_PARALLEL_TESTING')); @@ -48,9 +41,7 @@ public function testEnvironmentNoCustomVariablesParallelWithRecreate() $this->assertEquals(null, env('CUSTOM_ENV_VARIABLE_FOR_PARALLEL')); } - /** - * @group environmentNoCVParallelDrop - */ + #[Group('environmentNoCVParallelDrop')] public function testEnvironmentNoCustomVariablesParallelWithDrop() { $this->assertEquals(1, env('LARAVEL_PARALLEL_TESTING')); @@ -61,9 +52,7 @@ public function testEnvironmentNoCustomVariablesParallelWithDrop() $this->assertEquals(null, env('CUSTOM_ENV_VARIABLE_FOR_PARALLEL')); } - /** - * @group environmentCVPhpunit - */ + #[Group('environmentCVPhpunit')] public function testEnvironmentCustomVariablesPhpunit() { $this->assertEquals(null, env('LARAVEL_PARALLEL_TESTING')); @@ -73,9 +62,7 @@ public function testEnvironmentCustomVariablesPhpunit() $this->assertEquals(null, env('CUSTOM_ENV_VARIABLE_FOR_PARALLEL')); } - /** - * @group environmentCVParallel - */ + #[Group('environmentCVParallel')] public function testEnvironmentCustomVariablesParallel() { $this->assertEquals(1, env('LARAVEL_PARALLEL_TESTING')); @@ -85,9 +72,7 @@ public function testEnvironmentCustomVariablesParallel() $this->assertEquals(1, env('CUSTOM_ENV_VARIABLE_FOR_PARALLEL')); } - /** - * @group environmentCVParallelRecreate - */ + #[Group('environmentCVParallelRecreate')] public function testEnvironmentCustomVariablesParallelWithRecreate() { $this->assertEquals(1, env('LARAVEL_PARALLEL_TESTING')); @@ -98,9 +83,7 @@ public function testEnvironmentCustomVariablesParallelWithRecreate() $this->assertEquals(1, env('CUSTOM_ENV_VARIABLE_FOR_PARALLEL')); } - /** - * @group environmentCVParallelDrop - */ + #[Group('environmentCVParallelDrop')] public function testEnvironmentCustomVariablesParallelWithDrop() { $this->assertEquals(1, env('LARAVEL_PARALLEL_TESTING')); diff --git a/tests/LaravelApp/tests/Feature/EnvironmentTest.php b/tests/LaravelApp/tests/Feature/EnvironmentTest.php index ea8fa9f..ace84d3 100644 --- a/tests/LaravelApp/tests/Feature/EnvironmentTest.php +++ b/tests/LaravelApp/tests/Feature/EnvironmentTest.php @@ -4,27 +4,27 @@ namespace Tests\Feature; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Tests\TestCase; -/** - * @group environment - */ +#[Group('environment')] class EnvironmentTest extends TestCase { - /** @test */ + #[Test] public function variableOnlyInDotEnv() { $this->assertEquals('VAL_IN_DOT_ENV', env('VAR_IN_DOT_ENV')); $this->assertEquals(null, env('VAR_IN_DOT_ENV_TESTING')); } - /** @test */ + #[Test] public function variableOnlyInPhpunit() { $this->assertEquals('VAL_IN_PHPUNIT', env('VAR_IN_PHPUNIT')); } - /** @test */ + #[Test] public function variableInDotEnvButOverriddenInPhpunit() { $this->assertEquals('VAL_OVERRIDDEN_IN_PHPUNIT', env('VAR_OVERRIDDEN_IN_PHPUNIT')); diff --git a/tests/LaravelApp/tests/Feature/EnvironmentTestingTest.php b/tests/LaravelApp/tests/Feature/EnvironmentTestingTest.php index 9879c2f..015f75c 100644 --- a/tests/LaravelApp/tests/Feature/EnvironmentTestingTest.php +++ b/tests/LaravelApp/tests/Feature/EnvironmentTestingTest.php @@ -4,27 +4,27 @@ namespace Tests\Feature; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use Tests\TestCase; -/** - * @group environmentTesting - */ +#[Group('environmentTesting')] class EnvironmentTestingTest extends TestCase { - /** @test */ + #[Test] public function variableOnlyInDotEnv() { $this->assertEquals(null, env('VAR_IN_DOT_ENV')); $this->assertEquals('VAL_IN_DOT_ENV_TESTING', env('VAR_IN_DOT_ENV_TESTING')); } - /** @test */ + #[Test] public function variableOnlyInPhpunit() { $this->assertEquals('VAL_IN_PHPUNIT', env('VAR_IN_PHPUNIT')); } - /** @test */ + #[Test] public function variableInDotEnvButOverriddenInPhpunit() { $this->assertEquals('VAL_OVERRIDDEN_IN_PHPUNIT', env('VAR_OVERRIDDEN_IN_PHPUNIT')); diff --git a/tests/LaravelApp/tests/Feature/ExampleWithCustomNameTest.php b/tests/LaravelApp/tests/Feature/ExampleWithCustomNameTest.php index 11a138a..1a80376 100644 --- a/tests/LaravelApp/tests/Feature/ExampleWithCustomNameTest.php +++ b/tests/LaravelApp/tests/Feature/ExampleWithCustomNameTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature; use NunoMaduro\Collision\Contracts\Adapters\Phpunit\HasPrintableTestCaseName; +use PHPUnit\Framework\Attributes\Group; use Tests\TestCase; class ExampleWithCustomNameTest extends TestCase implements HasPrintableTestCaseName @@ -24,9 +25,7 @@ public static function getLatestPrintableTestCaseMethodName(): string return 'my-custom-test-case-name'; } - /** - * @group custom-name - */ + #[Group('custom-name')] public function testPassExample() { $this->assertTrue(true); diff --git a/tests/LaravelApp/tests/Feature/ExampleWithUnexpectedOutputTest.php b/tests/LaravelApp/tests/Feature/ExampleWithUnexpectedOutputTest.php index 148e495..2eca680 100644 --- a/tests/LaravelApp/tests/Feature/ExampleWithUnexpectedOutputTest.php +++ b/tests/LaravelApp/tests/Feature/ExampleWithUnexpectedOutputTest.php @@ -4,13 +4,12 @@ namespace LaravelApp\tests\Feature; +use PHPUnit\Framework\Attributes\Group; use Tests\TestCase; class ExampleWithUnexpectedOutputTest extends TestCase { - /** - * @group unexpected-output - */ + #[Group('unexpected-output')] public function testPassExample() { echo 'This is an unexpected output'; diff --git a/tests/LaravelApp/tests/TestCase.php b/tests/LaravelApp/tests/TestCase.php index 2932d4a..6d8abf3 100644 --- a/tests/LaravelApp/tests/TestCase.php +++ b/tests/LaravelApp/tests/TestCase.php @@ -2,9 +2,21 @@ namespace Tests; +use Illuminate\Contracts\Console\Kernel; +use Illuminate\Foundation\Application; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { - use CreatesApplication; + /** + * Create a new application instance. + */ + public function createApplication(): Application + { + $app = require __DIR__.'/../bootstrap/app.php'; + + $app->make(Kernel::class)->bootstrap(); + + return $app; + } } diff --git a/tests/LaravelApp/tests/Unit/ExampleTest.php b/tests/LaravelApp/tests/Unit/ExampleTest.php index 8b6fbbd..4bb20c7 100644 --- a/tests/LaravelApp/tests/Unit/ExampleTest.php +++ b/tests/LaravelApp/tests/Unit/ExampleTest.php @@ -2,23 +2,20 @@ namespace Tests\Unit; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; error_reporting(E_ALL); class ExampleTest extends TestCase { - /** - * @group fail - */ + #[Group('fail')] public function testFailExample() { $this->assertFalse(true); } - /** - * @group todo - */ + #[Group('todo')] public function testTodoExample() { $this->markTestSkipped('__TODO__'); @@ -29,9 +26,7 @@ public function testBasicTest() $this->assertTrue(true); } - /** - * @group notices - */ + #[Group('notices')] public function testUserNotice() { trigger_error('This is a user notice'); @@ -39,9 +34,7 @@ public function testUserNotice() $this->assertTrue(true); } - /** - * @group notices - */ + #[Group('notices')] public function testUserNoticeTwo() { trigger_error('This is another user notice'); @@ -49,9 +42,7 @@ public function testUserNoticeTwo() $this->assertTrue(true); } - /** - * @group warnings - */ + #[Group('warnings')] public function testWarning() { $this->blabla; @@ -59,9 +50,7 @@ public function testWarning() $this->assertTrue(true); } - /** - * @group warnings - */ + #[Group('warnings')] public function testUserWarning() { trigger_error('This is a user warning', E_USER_WARNING); @@ -69,9 +58,7 @@ public function testUserWarning() $this->assertTrue(true); } - /** - * @group deprecations - */ + #[Group('deprecations')] public function testDeprecation() { str_contains(null, null); @@ -79,9 +66,7 @@ public function testDeprecation() $this->assertTrue(true); } - /** - * @group deprecations - */ + #[Group('deprecations')] public function testUserDeprecation() { trigger_deprecation('foo', '1.0', 'This is a deprecation description'); diff --git a/tests/LaravelApp/vendor/autoload.php b/tests/LaravelApp/vendor/autoload.php index b3e5f92..5ca6060 100644 --- a/tests/LaravelApp/vendor/autoload.php +++ b/tests/LaravelApp/vendor/autoload.php @@ -1,3 +1,3 @@ runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--group', 'coverage']); @@ -17,40 +19,45 @@ public function testCoverage(): void $this->assertStringContainsString('0.0', $output); $this->assertStringContainsString('Total: ', $output); + /** $output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--parallel', '--group', 'coverage']); $this->assertStringContainsString('Models/User', $output); $this->assertStringContainsString('0.0', $output); $this->assertStringContainsString('Total: ', $output); + */ } - /** @test */ + #[Test] public function testMinCoverage(): void { $output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--min=0', '--group', 'coverage'], 0); $this->assertStringContainsString('Total: ', $output); $this->assertStringNotContainsString('Code coverage below expected', $output); + /** $output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--min=10', '--parallel', '--group', 'coverage'], 1); $this->assertStringContainsString('Total: ', $output); $this->assertStringContainsString('Code coverage below expected', $output); - + */ $output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--min=99', '--group', 'coverage'], 1); $this->assertStringContainsString('Total: ', $output); $this->assertStringContainsString('Code coverage below expected', $output); + /** $output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--min=99', '--parallel', '--group', 'coverage'], 1); $this->assertStringContainsString('Total: ', $output); $this->assertStringContainsString('Code coverage below expected', $output); + */ } - /** @test */ + #[Test] public function testAnsi(): void { $this->runTests(['./tests/LaravelApp/artisan', 'test', '--ansi'], 1); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--no-ansi'], 1); } - /** @test */ + #[Test] public function testEnv(): void { $this->runTests([ @@ -63,12 +70,14 @@ public function testEnv(): void $this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environment']); + /** $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environment']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--recreate-databases', '--group', 'environment']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--drop-databases', '--group', 'environment']); + */ } - /** @test */ + #[Test] public function testEnvTesting(): void { file_put_contents(__DIR__.'/../../../tests/LaravelApp/.env.testing', <<<'EOF' @@ -87,20 +96,20 @@ public function testEnvTesting(): void $this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environmentTesting']); + /** $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environmentTesting']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--recreate-databases', '--group', 'environmentTesting']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--drop-databases', '--group', 'environmentTesting']); + */ } - /** - * @afterClass - */ + #[AfterClass] public static function cleanUp() { @unlink(__DIR__.'/../../../tests/LaravelApp/.env.testing'); } - /** @test */ + #[Test] public function testExtendableCustomVariables(): void { $this->runTests([ @@ -114,23 +123,29 @@ public function testExtendableCustomVariables(): void // Without Custom Variables (-c|--custom-argument) $this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environmentNoCVPhpunit']); + /** $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environmentNoCVParallel']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--recreate-databases', '--group', 'environmentNoCVParallelRecreate']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--drop-databases', '--group', 'environmentNoCVParallelDrop']); + */ // With Custom Variables (-c) $this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--group', 'environmentCVPhpunit']); + /** $this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--parallel', '--group', 'environmentCVParallel']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--parallel', '--recreate-databases', '--group', 'environmentCVParallelRecreate']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--parallel', '--drop-databases', '--group', 'environmentCVParallelDrop']); + */ // With Custom Variables (--custom-argument) $this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--group', 'environmentCVPhpunit']); + /** $this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--parallel', '--group', 'environmentCVParallel']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--parallel', '--recreate-databases', '--group', 'environmentCVParallelRecreate']); $this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--parallel', '--drop-databases', '--group', 'environmentCVParallelDrop']); + */ } private function runTests(array $arguments, int $expectedExitCode = 0): string @@ -161,7 +176,7 @@ private function runTests(array $arguments, int $expectedExitCode = 0): string return $output; } - /** @test */ + #[Test] public function testProfile(): void { $output = $this->runTests([ diff --git a/tests/Unit/Adapters/LaravelTest.php b/tests/Unit/Adapters/LaravelTest.php index 3c204fb..087d572 100755 --- a/tests/Unit/Adapters/LaravelTest.php +++ b/tests/Unit/Adapters/LaravelTest.php @@ -12,6 +12,7 @@ use NunoMaduro\Collision\Adapters\Laravel\ExceptionHandler; use NunoMaduro\Collision\Adapters\Laravel\Inspector; use NunoMaduro\Collision\Provider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionMethod; use Symfony\Component\Console\Exception\InvalidArgumentException; @@ -19,7 +20,7 @@ class LaravelTest extends TestCase { - /** @test */ + #[Test] public function itIsRegisteredOnArtisan(): void { $app = $this->createApplication(); @@ -31,7 +32,7 @@ public function itIsRegisteredOnArtisan(): void $this->assertInstanceOf(ExceptionHandler::class, $app->make(ExceptionHandlerContract::class)); } - /** @test */ + #[Test] public function itIsNotRegisteredOnTesting(): void { $app = $this->createApplication(); @@ -43,7 +44,7 @@ public function itIsNotRegisteredOnTesting(): void $this->assertNotInstanceOf(ExceptionHandler::class, $app->make(ExceptionHandlerContract::class)); } - /** @test */ + #[Test] public function itIsNotRegisteredOnHttp(): void { $app = $this->createApplication(); @@ -55,7 +56,7 @@ public function itIsNotRegisteredOnHttp(): void $this->assertNotInstanceOf(ExceptionHandler::class, $app->make(ExceptionHandlerContract::class)); } - /** @test */ + #[Test] public function exceptionHandlerRespectsIsContract(): void { $app = $this->createApplication(); @@ -66,7 +67,7 @@ public function exceptionHandlerRespectsIsContract(): void ); } - /** @test */ + #[Test] public function itReportsToTheOriginalExceptionHandler(): void { $app = $this->createApplication(); @@ -78,7 +79,7 @@ public function itReportsToTheOriginalExceptionHandler(): void $exceptionHandler->report($exception); } - /** @test */ + #[Test] public function itRendersToTheOriginalExceptionHandler(): void { $app = $this->createApplication(); @@ -91,7 +92,7 @@ public function itRendersToTheOriginalExceptionHandler(): void $exceptionHandler->render($request, $exception); } - /** @test */ + #[Test] public function itRendersNonSymfonyConsoleExceptionsWithSymfony(): void { $app = $this->createApplication(); @@ -105,7 +106,7 @@ public function itRendersNonSymfonyConsoleExceptionsWithSymfony(): void $exceptionHandler->renderForConsole($output, $exception); } - /** @test */ + #[Test] public function isInspectorGetsTrace(): void { $method = new ReflectionMethod(Inspector::class, 'getTrace'); @@ -116,7 +117,7 @@ public function isInspectorGetsTrace(): void $this->assertSame($method->invokeArgs(new Inspector($exception), [$exception]), $exception->getTrace()); } - /** @test */ + #[Test] public function itProvidesOnlyTheProviderContract(): void { $app = $this->createApplication(); diff --git a/tests/Unit/Adapters/PhpunitTest.php b/tests/Unit/Adapters/PhpunitTest.php index 99d55a1..6f38656 100755 --- a/tests/Unit/Adapters/PhpunitTest.php +++ b/tests/Unit/Adapters/PhpunitTest.php @@ -5,12 +5,13 @@ namespace Tests\Unit\Adapters; use NunoMaduro\Collision\Adapters\Phpunit\Printers\DefaultPrinter; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; class PhpunitTest extends TestCase { - /** @test */ + #[Test] public function itIsAPrinter(): void { $this->assertInstanceOf(DefaultPrinter::class, new DefaultPrinter(true)); @@ -31,7 +32,7 @@ private function assertConsoleOutputNotContainsString(string $needle, string $co self::assertStringNotContainsString($needle, $this->stripConsoleOutput($consoleOutput)); } - /** @test */ + #[Test] public function itHasTests(): void { $output = $this->runCollisionTests([ @@ -57,7 +58,7 @@ public function itHasTests(): void ); } - /** @test */ + #[Test] public function itHasCustomTestCaseName(): void { $output = $this->runCollisionTests([ @@ -76,7 +77,7 @@ public function itHasCustomTestCaseName(): void ); } - /** @test */ + #[Test] public function itPrintedUnexpectedOutput(): void { $output = $this->runCollisionTests([ @@ -96,7 +97,7 @@ public function itPrintedUnexpectedOutput(): void ); } - /** @test */ + #[Test] public function itHasATodo(): void { $output = $this->runCollisionTests([ @@ -115,7 +116,7 @@ public function itHasATodo(): void ); } - /** @test */ + #[Test] public function itHasRecap(): void { $output = $this->runCollisionTests([ @@ -129,7 +130,7 @@ public function itHasRecap(): void ); } - /** @test */ + #[Test] public function itInformsTheUserWhenNoTestsAreExecuted(): void { $output = $this->runCollisionTests([ @@ -143,7 +144,7 @@ public function itInformsTheUserWhenNoTestsAreExecuted(): void ); } - /** @test */ + #[Test] public function itHasFailure(): void { $output = $this->runCollisionTests([], 1); @@ -199,7 +200,7 @@ private function runCollisionTests(array $arguments = [], int $exitCode = 0): st return $process->getOutput(); } - /** @test */ + #[Test] public function itHasOutputInStdoutWithBeStrictAboutOutputDuringTestsFalse(): void { $process = new Process([ diff --git a/tests/Unit/ArgumentFormatterTest.php b/tests/Unit/ArgumentFormatterTest.php index 774b24f..22c563a 100755 --- a/tests/Unit/ArgumentFormatterTest.php +++ b/tests/Unit/ArgumentFormatterTest.php @@ -5,11 +5,12 @@ namespace Tests\Unit; use NunoMaduro\Collision\ArgumentFormatter; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class ArgumentFormatterTest extends TestCase { - /** @test */ + #[Test] public function itFormatsAString(): void { $argumentFormatter = new ArgumentFormatter(); @@ -21,7 +22,7 @@ public function itFormatsAString(): void $this->assertEquals($result, '"foo"'); } - /** @test */ + #[Test] public function itFormatsALongString(): void { $argumentFormatter = new ArgumentFormatter(); @@ -33,7 +34,7 @@ public function itFormatsALongString(): void $this->assertEquals($result, '"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque volutpat, enim ut ultrices efficitur, sapien justo viverra tellus, a auctor lacus risus quis neque. Proin dictum tincidunt placerat. Suspendisse vehicula arcu elit, a lobortis sem luctus sed. Nullam vehicula, leo sit amet malesuada imperdiet, felis orci tempus risus, non tincidunt lorem massa id ipsum. Nulla sem justo, feugiat et egestas eu, posuere ut dui. Cras quis bibendum justo. Cras finibus consequat mattis. Vivamus eu pretium odio. Suspendisse quis lacus molestie, tempus neque a, sagittis nunc. Etiam posuere quam sed metus volutpat facilisis. Maecenas vel dolor in neque maximus eleifend at in turpis. Nullam a tellus eget tortor volutpat ultricies aliquam sit amet felis. Phasellus efficitur massa consectetur, pharetra lacus eu, ultricies nunc. In sed sapien dignissim, convallis diam id, condimentum elit. Aenean feugiat euismod arcu, et mollis lacus vehicula eget. Aenean bibendum varius lorem vitae efficitur. Duis ege..."'); } - /** @test */ + #[Test] public function itFormatsAArray(): void { $argumentFormatter = new ArgumentFormatter(); @@ -45,7 +46,7 @@ public function itFormatsAArray(): void $this->assertEquals($result, '["bar", "value"]'); } - /** @test */ + #[Test] public function itFormatsAObject(): void { $argumentFormatter = new ArgumentFormatter(); diff --git a/tests/Unit/CoverageTest.php b/tests/Unit/CoverageTest.php index 35b9792..9c924c9 100644 --- a/tests/Unit/CoverageTest.php +++ b/tests/Unit/CoverageTest.php @@ -5,11 +5,12 @@ namespace Tests\Unit; use NunoMaduro\Collision\Coverage; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class CoverageTest extends TestCase { - /** @test */ + #[Test] public function testGetPath(): void { $temporaryDirectory = implode(DIRECTORY_SEPARATOR, [ @@ -21,7 +22,7 @@ public function testGetPath(): void $this->assertSame($temporaryDirectory, Coverage::getPath()); } - /** @test */ + #[Test] public function testUsingXdebug(): void { $this->assertTrue(Coverage::usingXdebug()); diff --git a/tests/Unit/HandlerTest.php b/tests/Unit/HandlerTest.php index 681a4b4..27e8c8f 100755 --- a/tests/Unit/HandlerTest.php +++ b/tests/Unit/HandlerTest.php @@ -6,12 +6,13 @@ use NunoMaduro\Collision\Handler; use NunoMaduro\Collision\Writer; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\ConsoleOutput; class HandlerTest extends TestCase { - /** @test */ + #[Test] public function itSetsTheOutput(): void { $output = new ConsoleOutput(); @@ -21,7 +22,7 @@ public function itSetsTheOutput(): void $this->assertSame($output, $handler->getWriter()->getOutput()); } - /** @test */ + #[Test] public function itGetsTheWriter(): void { $writer = new Writer(); diff --git a/tests/Unit/ProviderTest.php b/tests/Unit/ProviderTest.php index 62692e7..d9095c8 100755 --- a/tests/Unit/ProviderTest.php +++ b/tests/Unit/ProviderTest.php @@ -6,13 +6,14 @@ use NunoMaduro\Collision\Handler; use NunoMaduro\Collision\Provider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Whoops\Run; use Whoops\RunInterface; class ProviderTest extends TestCase { - /** @test */ + #[Test] public function itRegistersTheErrorHandler(): void { $handler = new Handler(); @@ -30,7 +31,7 @@ public function itRegistersTheErrorHandler(): void (new Provider($runMock, $handler))->register(); } - /** @test */ + #[Test] public function itGetsTheHandler(): void { $handler = new Handler(); diff --git a/tests/Unit/TestExceptionTest.php b/tests/Unit/TestExceptionTest.php index 5aa03b3..aef1643 100644 --- a/tests/Unit/TestExceptionTest.php +++ b/tests/Unit/TestExceptionTest.php @@ -6,11 +6,12 @@ use NunoMaduro\Collision\Exceptions\TestException; use PHPUnit\Event\Code\Throwable; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class TestExceptionTest extends TestCase { - /** @test */ + #[Test] public function itShortensContainsErrorMessages(): void { $message = <<<'EOF' @@ -36,7 +37,7 @@ public function itShortensContainsErrorMessages(): void $this->assertStringContainsString($expect, strip_tags($testException->getMessage())); } - /** @test */ + #[Test] public function itShortensNotContainErrorMessages(): void { $message = <<<'EOF' diff --git a/tests/Unit/WriterTest.php b/tests/Unit/WriterTest.php index d127fe3..3a94c82 100755 --- a/tests/Unit/WriterTest.php +++ b/tests/Unit/WriterTest.php @@ -8,6 +8,7 @@ use NunoMaduro\Collision\Highlighter; use NunoMaduro\Collision\SolutionsRepositories\NullSolutionsRepository; use NunoMaduro\Collision\Writer; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\ConsoleOutput; @@ -20,7 +21,7 @@ class WriterTest extends TestCase { - /** @test */ + #[Test] public function itGetsTheOutput(): void { $writer = new Writer(new NullSolutionsRepository(), $output = new ConsoleOutput()); @@ -28,7 +29,7 @@ public function itGetsTheOutput(): void $this->assertEquals($writer->getOutput(), $output); } - /** @test */ + #[Test] public function itSetsTheOutput(): void { $writer = (new Writer())->setOutput($output = new ConsoleOutput()); @@ -36,7 +37,7 @@ public function itSetsTheOutput(): void $this->assertEquals($writer->getOutput(), $output); } - /** @test */ + #[Test] public function itWritesTheException(): void { $inspector = new Inspector(HelloWorldFile1::say()); @@ -76,7 +77,7 @@ public function itWritesTheException(): void ); } - /** @test */ + #[Test] public function itWritesDetails(): void { $inspector = new Inspector(HelloWorldFile1::say()); @@ -115,7 +116,7 @@ public function itWritesDetails(): void $this->assertStringContainsString($result, $writer->getOutput()->fetch()); } - /** @test */ + #[Test] public function itIgnoresClosures(): void { $inspector = new Inspector(HelloWorldFile1::say()); @@ -142,7 +143,7 @@ public function itIgnoresClosures(): void ); } - /** @test */ + #[Test] public function itIgnoresFolders(): void { $inspector = new Inspector(HelloWorldFile1::say()); @@ -168,7 +169,7 @@ public function itIgnoresFolders(): void ); } - /** @test */ + #[Test] public function itHidesEditor(): void { $inspector = new Inspector(HelloWorldFile1::say()); @@ -198,7 +199,7 @@ public function itHidesEditor(): void ); } - /** @test */ + #[Test] public function itHidesTrace(): void { $inspector = new Inspector(HelloWorldFile1::say()); @@ -233,7 +234,7 @@ public function itHidesTrace(): void ); } - /** @test */ + #[Test] public function itSupportsRenderlessContracts(): void { $inspector = new Inspector(HelloWorldFile4::say()); @@ -253,7 +254,7 @@ public function itSupportsRenderlessContracts(): void ); } - /** @test */ + #[Test] public function itSupportsCustomEditorContracts(): void { $inspector = new Inspector(HelloWorldFile5::say());