diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be5853a..2adaeb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,28 +11,17 @@ jobs: strategy: fail-fast: true matrix: - php: [8.0, 8.1, 8.2] - laravel: ['9.*', '10.*', '11.*', '12.*'] + php: [8.3, 8.4, 8.5] + laravel: ['10.*', '11.*', '12.*', '13.*'] include: + - laravel: 13.* + testbench: 11.* + - laravel: 12.* + testbench: 10.* - laravel: 11.* testbench: 9.* - laravel: 10.* testbench: 8.* - - laravel: 9.* - testbench: 7.* - - laravel: 12.* - testbench: 10.* - exclude: - - php: 8.0 - laravel: 10.* - - laravel: 11.* - php: 8.0 - - laravel: 11.* - php: 8.1 - - laravel: 12.* - php: 8.0 - - laravel: 12.* - php: 8.1 name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} diff --git a/.gitignore b/.gitignore index 42fc281..e470fe8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.lock .vscode .php_cs.cache build/* +.phpunit.cache diff --git a/composer.json b/composer.json index bb4e5a0..6526389 100644 --- a/composer.json +++ b/composer.json @@ -19,15 +19,15 @@ ], "require": { "php": "^8.0", - "illuminate/support": "^9.0|^10.0|^11.0|^12.0", + "illuminate/support": "^10.0|^11.0|^12.0|^13.0", "league/openapi-psr7-validator": "^0.14|^0.15|^0.16|^0.17|^0.18|^0.19|^0.20|^0.21|^0.22", "nyholm/psr7": "^1.3", "symfony/psr-http-message-bridge": "^2.0|^7.0" }, "require-dev": { - "orchestra/testbench": "7.*|^8.0|^9.0|^10.0", + "orchestra/testbench": "^8.0|^9.0|^10.0|^11.0", "mockery/mockery": "^1.3.1", - "phpunit/phpunit": "^9.0|^10.5|^11.5.3", + "phpunit/phpunit": "^10.5|^11.5.3|^12.5|^13.0", "fakerphp/faker": "^1.9.1" }, "autoload": { diff --git a/tests/ValidatesRequestsTest.php b/tests/ValidatesRequestsTest.php index 0d3b32e..4f3e8c9 100644 --- a/tests/ValidatesRequestsTest.php +++ b/tests/ValidatesRequestsTest.php @@ -10,6 +10,8 @@ use League\OpenAPIValidation\PSR7\Exception\NoPath; use League\OpenAPIValidation\PSR7\OperationAddress; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; class ValidatesRequestsTest extends TestCase @@ -24,10 +26,8 @@ protected function setUp(): void $this->app['config']->set('openapi_validator.spec_path', __DIR__.'/fixtures/OpenAPI.yaml'); } - /** - * @test - * @dataProvider provideValidationScenarios - */ + #[Test] + #[DataProvider('provideValidationScenarios')] public function testValidatesRequests(array $requestData, bool $expectSuccess, ?string $expectedException = null) { extract($requestData); diff --git a/tests/ValidatesRequestsWithSkipTest.php b/tests/ValidatesRequestsWithSkipTest.php index f7d03dd..26a58fa 100644 --- a/tests/ValidatesRequestsWithSkipTest.php +++ b/tests/ValidatesRequestsWithSkipTest.php @@ -10,6 +10,8 @@ use League\OpenAPIValidation\PSR7\Exception\NoPath; use League\OpenAPIValidation\PSR7\OperationAddress; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; class ValidatesRequestsWithSkipTest extends TestCase @@ -24,10 +26,8 @@ protected function setUp(): void $this->app['config']->set('openapi_validator.spec_path', __DIR__.'/fixtures/OpenAPI.yaml'); } - /** - * @test - * @dataProvider provideValidationScenarios - */ + #[Test] + #[DataProvider('provideValidationScenarios')] public function testValidatesRequests(array $requestData, bool $expectSuccess, ?string $expectedException = null) { extract($requestData); diff --git a/tests/ValidatesResponsesTest.php b/tests/ValidatesResponsesTest.php index e79e7dc..84baa0a 100644 --- a/tests/ValidatesResponsesTest.php +++ b/tests/ValidatesResponsesTest.php @@ -11,6 +11,8 @@ use League\OpenAPIValidation\PSR7\OperationAddress; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; class ValidatesResponsesTest extends TestCase { @@ -24,10 +26,8 @@ protected function setUp(): void $this->app['config']->set('openapi_validator.spec_path', __DIR__.'/fixtures/OpenAPI.yaml'); } - /** - * @test - * @dataProvider provideValidationScenarios - */ + #[Test] + #[DataProvider('provideValidationScenarios')] public function testValidatesResponses(OperationAddress $address, array $responseData, bool $expectSuccess, ?string $expectedException = null) { extract($responseData); diff --git a/tests/ValidatorBuildAndSetupTest.php b/tests/ValidatorBuildAndSetupTest.php index 68109a6..761af06 100644 --- a/tests/ValidatorBuildAndSetupTest.php +++ b/tests/ValidatorBuildAndSetupTest.php @@ -10,6 +10,8 @@ use Mockery; use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; class ValidatorBuildAndSetupTest extends TestCase @@ -18,10 +20,8 @@ class ValidatorBuildAndSetupTest extends TestCase use MockeryPHPUnitIntegration; use WithFaker; - /** - * @test - * @dataProvider provideSpecFormats - */ + #[Test] + #[DataProvider('provideSpecFormats')] public function testGetsOpenApiValidatorBuilder(string $extension) { $this->app['config']->set('openapi_validator.spec_path', __DIR__."/fixtures/OpenAPI.{$extension}"); @@ -38,10 +38,8 @@ public static function provideSpecFormats() ]; } - /** - * @test - * @dataProvider provideSpecUnknownFormats - */ + #[DataProvider('provideSpecUnknownFormats')] + #[Test] public function testThrowsExceptionForUnknownFormat(string $extension) { $this->app['config']->set('openapi_validator.spec_path', __DIR__ . "/fixtures/OpenAPI.{$extension}"); @@ -72,9 +70,7 @@ public function testSkipsRequestValidation() $this->assertTrue($this->shouldSkipRequestValidation()); } - /** - * @test - */ + #[Test] public function testSkipsResponseValidation() { $this->withoutResponseValidation(); @@ -82,9 +78,7 @@ public function testSkipsResponseValidation() $this->assertTrue($this->shouldSkipResponseValidation(Mockery::mock(Response::class))); } - /** - * @test - */ + #[Test] public function testSkipsValidation() { $this->withoutValidation(); @@ -94,10 +88,8 @@ public function testSkipsValidation() $this->assertTrue($this->shouldSkipResponseValidation(Mockery::mock(Response::class))); } - /** - * @test - * @dataProvider provideResponseCodes - */ + #[DataProvider('provideResponseCodes')] + #[Test] public function testSkipsResponseCodes($responseCode, $codesToSkip, bool $expected) { if (is_callable($responseCode)) { @@ -158,9 +150,7 @@ function ($faker) { yield 'Doesn\'t skip valid regex' => [206, '2[1-9]6', false]; } - /** - * @test - */ + #[Test] public function testBypassesAuthenticationInRequests() { $originRequest = new SymfonyRequest(); @@ -169,9 +159,7 @@ public function testBypassesAuthenticationInRequests() $this->assertNotSame($originRequest, $request); } - /** - * @test - */ + #[Test] public function testDontSpoofAuthenticationInRequests() { $originRequest = new SymfonyRequest();