diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5b55e30..261a638 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,6 +18,10 @@ jobs: - '5.4.*' - '6.0.*' - '6.2.*' + - '7.0.*' + exclude: + - php: '8.1' + symfony-versions: '7.0.*' include: - php: '7.4' symfony-versions: '^4.4' @@ -34,7 +38,7 @@ jobs: - description: 'Log Code Coverage' php: '8.2' coverage: 'xdebug' - symfony-versions: '^6.2' + symfony-versions: '^7.0' name: PHP ${{ matrix.php }} Symfony ${{ matrix.symfony-versions }} ${{ matrix.description }} steps: diff --git a/.gitignore b/.gitignore index 0f35a13..c68eba9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /composer.lock /build/ /.phpunit.result.cache +/.phpunit.cache /node_modules/ /.idea/ /package-lock.json diff --git a/composer.json b/composer.json index 93c1d06..70b553b 100644 --- a/composer.json +++ b/composer.json @@ -27,19 +27,19 @@ "license": "MIT", "require": { "ext-json": "*", - "php": "^7.4 || ^8.0", - "behat/behat": "^3.0", - "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0", - "symfony/http-client": "^4.4 || ^5.4 || ^6.0", - "symfony/http-kernel": "^4.4 || ^5.4 || ^6.0", - "symfony/routing": "^4.4 || ^5.4 || ^6.0", + "php": "^7.4 || ^8.0 || ^8.2", + "behat/behat": "^3.14", + "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0 || ^7.0", + "symfony/http-client": "^4.4 || ^5.4 || ^6.0 || ^7.0", + "symfony/http-kernel": "^4.4 || ^5.4 || ^6.0 || ^7.0", + "symfony/routing": "^4.4 || ^5.4 || ^6.0 || ^7.0", "macpaw/similar-arrays": "^1.0" }, "require-dev": { - "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^9.3", - "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.6" + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^11.0", + "slevomat/coding-standard": "^8.14", + "squizlabs/php_codesniffer": "^3.8" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index afc133c..f245a52 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,25 +1,24 @@ - - - tests - - - - - ./src - - - - - + + + tests + + + + + + + + + + ./src + + diff --git a/src/Context/ApiContext.php b/src/Context/ApiContext.php index 0e99d3f..aa6273d 100644 --- a/src/Context/ApiContext.php +++ b/src/Context/ApiContext.php @@ -136,7 +136,11 @@ public function iSendRequestToRoute( if (Request::METHOD_GET === $method) { $queryString = http_build_query($this->requestParams); - } elseif (Request::METHOD_POST === $method || Request::METHOD_PATCH === $method || Request::METHOD_PUT === $method) { + } elseif ( + Request::METHOD_POST === $method + || Request::METHOD_PATCH === $method + || Request::METHOD_PUT === $method + ) { $postFields = $this->requestParams; } diff --git a/tests/DependencyInjection/BehatApiContextExtensionTest.php b/tests/DependencyInjection/BehatApiContextExtensionTest.php index ce50920..5f67969 100644 --- a/tests/DependencyInjection/BehatApiContextExtensionTest.php +++ b/tests/DependencyInjection/BehatApiContextExtensionTest.php @@ -7,6 +7,7 @@ use BehatApiContext\Context\ApiContext; use BehatApiContext\DependencyInjection\BehatApiContextExtension; use BehatApiContext\Service\ResetManager\DoctrineResetManager; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -14,6 +15,7 @@ class BehatApiContextExtensionTest extends TestCase { + #[Test] public function testWithEmptyConfig(): void { $container = $this->createContainerFromFixture('empty_bundle_config'); @@ -24,6 +26,7 @@ public function testWithEmptyConfig(): void self::assertCount(0, $methodCalls); } + #[Test] public function testWithFilledConfig(): void { $container = $this->createContainerFromFixture('filled_bundle_config'); diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 77b9304..bb74afe 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -6,11 +6,13 @@ use BehatApiContext\DependencyInjection\Configuration; use BehatApiContext\Service\ResetManager\DoctrineResetManager; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Processor; final class ConfigurationTest extends TestCase { + #[Test] public function testProcessConfigurationWithEmptyConfiguration(): void { $expectedBundleDefaultConfig = [ @@ -20,6 +22,7 @@ public function testProcessConfigurationWithEmptyConfiguration(): void $this->assertSame($expectedBundleDefaultConfig, $this->processConfiguration([])); } + #[Test] public function testProcessConfigurationWithDefaultConfiguration(): void { $config = [ @@ -35,6 +38,7 @@ public function testProcessConfigurationWithDefaultConfiguration(): void $this->assertSame($expectedBundleDefaultConfig, $this->processConfiguration($config)); } + #[Test] public function testProcessConfigurationWithFilledConfiguration(): void { $config = [ diff --git a/tests/Unit/Context/ApiContextTest.php b/tests/Unit/Context/ApiContextTest.php index 99ba9b0..66d3f2e 100644 --- a/tests/Unit/Context/ApiContextTest.php +++ b/tests/Unit/Context/ApiContextTest.php @@ -6,6 +6,8 @@ use Behat\Gherkin\Node\PyStringNode; use BehatApiContext\Context\ApiContext; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use RuntimeException; use Symfony\Component\HttpFoundation\RequestStack; @@ -27,12 +29,8 @@ protected function setUp(): void $this->apiContext = new ApiContext($routerMock, $requestStackMock, $kernelMock); } - /** - * @param PyStringNode $paramsValues - * @param string $initialParamValue - * - * @dataProvider getTheRequestContainsParamsSuccess - */ + #[Test] + #[DataProvider('getTheRequestContainsParamsSuccess')] public function testTheRequestContainsParamsSuccess(PyStringNode $paramsValues, string $initialParamValue): void { $this->assertTrue(str_contains($paramsValues->getStrings()[3], $initialParamValue)); @@ -84,18 +82,15 @@ public function testTheRequestContainsParamsSuccess(PyStringNode $paramsValues, ); } - /** - * @param PyStringNode $paramsValues - * - * @dataProvider getTheRequestContainsParamsRuntimeException - */ + #[Test] + #[DataProvider('getTheRequestContainsParamsRuntimeException')] public function testTheRequestContainsParamsRuntimeException(PyStringNode $paramsValues): void { $this->expectException(RuntimeException::class); $this->apiContext->theRequestContainsParams($paramsValues); } - public function getTheRequestContainsParamsSuccess(): array + public static function getTheRequestContainsParamsSuccess(): array { return [ [ @@ -122,7 +117,7 @@ public function getTheRequestContainsParamsSuccess(): array ]; } - public function getTheRequestContainsParamsRuntimeException(): array + public static function getTheRequestContainsParamsRuntimeException(): array { return [ [ diff --git a/tests/Unit/Service/ArrayManagerTest.php b/tests/Unit/Service/ArrayManagerTest.php index 25b1e92..d744e79 100644 --- a/tests/Unit/Service/ArrayManagerTest.php +++ b/tests/Unit/Service/ArrayManagerTest.php @@ -5,6 +5,8 @@ namespace BehatApiContext\Tests\Unit\Service; use BehatApiContext\Service\StringManager; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use RuntimeException; use PHPUnit\Framework\TestCase; @@ -21,13 +23,8 @@ protected function setUp(): void $this->stringManager = new StringManager(); } - /** - * @param array $substitutionValues - * @param string $initialString - * @param string $resultString - * - * @dataProvider getSubstituteValuesDataProvider - */ + #[Test] + #[DataProvider('getSubstituteValuesDataProvider')] public function testSubstituteValuesSuccess( array $substitutionValues, string $initialString, @@ -37,7 +34,7 @@ public function testSubstituteValuesSuccess( self::assertSame($resultString, $result); } - public function getSubstituteValuesDataProvider(): array + public static function getSubstituteValuesDataProvider(): array { return [ [ @@ -81,6 +78,7 @@ public function getSubstituteValuesDataProvider(): array ]; } + #[Test] public function testSubstituteValuesKeyNotFound(): void { $substitutionValues = ['headerKey' => 'headerValue']; @@ -91,6 +89,7 @@ public function testSubstituteValuesKeyNotFound(): void $this->stringManager->substituteValues($substitutionValues, $initialString); } + #[Test] public function testSubstituteValuesInvalidSyntax(): void { $substitutionValues = ['headerKey' => 'headerValue'];