diff --git a/composer.json b/composer.json index 7cca618..497fdd8 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "symfony/psr-http-message-bridge": "^2.1" }, "require-dev": { - "phpunit/phpunit": "^9.5.27", + "phpunit/phpunit": "^10.0", "phpstan/phpstan": "^1.8", "squizlabs/php_codesniffer": "^3.7" }, diff --git a/phpunit.xml b/phpunit.xml index 3ca25f0..3357b93 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,27 +1,13 @@ - - - - tests - - - - - - src - - + + + + tests + + + + + src + + diff --git a/tests/ApiProblemBuilderTest.php b/tests/ApiProblemBuilderTest.php index 4c8ec8b..37b9dcf 100644 --- a/tests/ApiProblemBuilderTest.php +++ b/tests/ApiProblemBuilderTest.php @@ -6,17 +6,19 @@ use Membrane\OpenAPI\Exception\CannotProcessRequest; use Membrane\Renderer\Renderer; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; -/** - * @covers \Membrane\Laravel\ApiProblemBuilder - * @uses \Membrane\Laravel\ToSymfony - */ +#[CoversClass(ApiProblemBuilder::class)] +#[UsesClass(ToSymfony::class)] class ApiProblemBuilderTest extends TestCase { - /** @test */ + #[Test] public function buildFromRendererTest(): void { $expected = [ @@ -40,7 +42,7 @@ public function buildFromRendererTest(): void self::assertEquals($expected, json_decode($actual->getContent(), true)); } - public function dataSetsToBuildFromException(): array + public static function dataSetsToBuildFromException(): array { return [ 'path not found, no apiResponseTypes' => [ @@ -90,11 +92,9 @@ public function dataSetsToBuildFromException(): array ], ]; } - - /** - * @test - * @dataProvider dataSetsToBuildFromException - */ + + #[Test] + #[DataProvider('dataSetsToBuildFromException')] public function buildFromExceptionTest( CannotProcessRequest $exception, SymfonyResponse $expected, diff --git a/tests/Middleware/RequestValidationTest.php b/tests/Middleware/RequestValidationTest.php index 1076e02..fc36aee 100644 --- a/tests/Middleware/RequestValidationTest.php +++ b/tests/Middleware/RequestValidationTest.php @@ -8,20 +8,25 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use Membrane\Laravel\ApiProblemBuilder; +use Membrane\Laravel\ToPsr7; +use Membrane\Laravel\ToSymfony; use Membrane\OpenAPI\Exception\CannotProcessRequest; use Membrane\OpenAPI\Method; use Membrane\Result\Result; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; -/** - * @covers \Membrane\Laravel\Middleware\RequestValidation - * @uses \Membrane\Laravel\ApiProblemBuilder - * @uses \Membrane\Laravel\ToPsr7 - * @uses \Membrane\Laravel\ToSymfony - */ + +#[CoversClass(RequestValidation::class)] +#[UsesClass(ApiProblemBuilder::class)] +#[UsesClass(ToPsr7::class)] +#[UsesClass(ToSymfony::class)] class RequestValidationTest extends TestCase { - /** @test */ + #[Test] public function registersResultInstanceInContainer(): void { $url = '/pets?limit=5&tags[]=cat&tags[]=tabby'; @@ -44,7 +49,7 @@ public function registersResultInstanceInContainer(): void $sut->handle(Request::create($url), fn($var) => new Response()); } - public function dataSetsThatThrowCannotProcessRequest(): array + public static function dataSetsThatThrowCannotProcessRequest(): array { return [ 'path not found' => [ @@ -62,10 +67,8 @@ public function dataSetsThatThrowCannotProcessRequest(): array } - /** - * @test - * @dataProvider dataSetsThatThrowCannotProcessRequest - */ + #[Test] + #[DataProvider('dataSetsThatThrowCannotProcessRequest')] public function catchesCannotProcessRequest(string $path, Method $method, CannotProcessRequest $expected): void { $apiProblemBuilder = self::createMock(ApiProblemBuilder::class); diff --git a/tests/Middleware/ResponseJsonFlatTest.php b/tests/Middleware/ResponseJsonFlatTest.php index 7e96c11..8f61f6d 100644 --- a/tests/Middleware/ResponseJsonFlatTest.php +++ b/tests/Middleware/ResponseJsonFlatTest.php @@ -7,21 +7,25 @@ use Illuminate\Contracts\Container\Container; use Illuminate\Http\Request; use Membrane\Laravel\ApiProblemBuilder; +use Membrane\Laravel\ToSymfony; use Membrane\Result\FieldName; use Membrane\Result\Message; use Membrane\Result\MessageSet; use Membrane\Result\Result; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; -/** - * @covers \Membrane\Laravel\Middleware\ResponseJsonFlat - * @uses \Membrane\Laravel\ApiProblemBuilder - * @uses \Membrane\Laravel\ToSymfony - */ + +#[CoversClass(ResponseJsonFlat::class)] +#[UsesClass(ApiProblemBuilder::class)] +#[UsesClass(ToSymfony::class)] class ResponseJsonFlatTest extends TestCase { - public function dataSetsToHandle(): array + public static function dataSetsToHandle(): array { return [ 'valid results return valid responses' => [ @@ -43,10 +47,8 @@ public function dataSetsToHandle(): array ]; } - /** - * @test - * @dataProvider dataSetsToHandle - */ + #[Test] + #[DataProvider('dataSetsToHandle')] public function handleTest(Result $result, SymfonyResponse $expected): void { $request = self::createStub(Request::class); diff --git a/tests/Middleware/ResponseJsonNestedTest.php b/tests/Middleware/ResponseJsonNestedTest.php index 3348f87..babae54 100644 --- a/tests/Middleware/ResponseJsonNestedTest.php +++ b/tests/Middleware/ResponseJsonNestedTest.php @@ -11,17 +11,20 @@ use Membrane\Result\Message; use Membrane\Result\MessageSet; use Membrane\Result\Result; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; -/** - * @covers \Membrane\Laravel\Middleware\ResponseJsonNested - * @uses \Membrane\Laravel\ApiProblemBuilder - * @uses \Membrane\Laravel\ToSymfony - */ + +#[CoversClass('\Membrane\Laravel\Middleware\ResponseJsonNested')] +#[UsesClass(' \Membrane\Laravel\ApiProblemBuilder')] +#[UsesClass(' \Membrane\Laravel\ToSymfony')] class ResponseJsonNestedTest extends TestCase { - public function dataSetsToHandle(): array + public static function dataSetsToHandle(): array { return [ 'valid results return valid responses' => [ @@ -43,10 +46,8 @@ public function dataSetsToHandle(): array ]; } - /** - * @test - * @dataProvider dataSetsToHandle - */ + #[Test] + #[DataProvider('dataSetsToHandle')] public function handleTest(Result $result, SymfonyResponse $expected): void { $request = self::createStub(Request::class);