diff --git a/CHANGELOG.md b/CHANGELOG.md index 670c66f..25955cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## v0.31.1 + +### Added + +- Use PHPUnit 11 attributes for testing helpers + ## v0.31.0 ### Fixed diff --git a/composer.json b/composer.json index 134f8de..c60139a 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "webonyx/graphql-php": "^14.11.3 || ^15" }, "require-dev": { - "bensampo/laravel-enum": "^3 || ^4.1", + "bensampo/laravel-enum": "^3 || ^4.1 || ^5 || ^6", "composer/composer": "^2", "ergebnis/composer-normalize": "^2.13", "guzzlehttp/guzzle": "^7", @@ -37,11 +37,10 @@ "php-http/mock-client": "^1.4", "phpstan/extension-installer": "^1", "phpstan/phpstan": "^1", - "phpstan/phpstan-deprecation-rules": "^1", "phpstan/phpstan-mockery": "^1", "phpstan/phpstan-phpunit": "^1", "phpstan/phpstan-strict-rules": "^1", - "phpunit/phpunit": "^9.5.2", + "phpunit/phpunit": "^9.5.2 || ^10 || ^11", "spawnia/phpunit-assert-directory": "^2", "symfony/var-dumper": "^5.2.3", "thecodingmachine/phpstan-safe-rule": "^1.1" diff --git a/phpstan.neon b/phpstan.neon index e715e2c..b697bd4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,9 +10,20 @@ parameters: - src - tests tmpDir: .build/phpstan + reportUnmatchedIgnoredErrors: false # As long as we support multiple PHP versions at once, there will be some dead spots ignoreErrors: + # Required in different versions - '#Call to deprecated method getNamespace\(\) of class Nette\\PhpGenerator\\ClassType#' + # Necessary when calling into generated client code, we know how it looks like - '#Unsafe usage of new static.*#' + # @property on interfaces or abstract classes + - '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#' + - '#Access to an undefined property Spawnia\\Sailor\\Result::\$data\.#' + - '#Access to an undefined property Spawnia\\Sailor\\ErrorFreeResult::\$data\.#' + # Due to different versions of bensampo/laravel-enum + - '#extends generic class BenSampo\\Enum\\Enum but does not specify its types: TValue#' + # Due to different versions of PHPUnit, attributes are backwards-compatible though + - '#Attribute class PHPUnit\\Framework\\Attributes\\After does not exist\.#' # Due to the workaround with ObjectLike::UNDEFINED - '#Default value of the parameter .+ \(string\) of method .+::make\(\) is incompatible with type .+#' - '#Default value of the parameter .+ \(string\) of method .+::execute\(\) is incompatible with type .+#' diff --git a/src/Operation.php b/src/Operation.php index 4ccce20..677eb5f 100644 --- a/src/Operation.php +++ b/src/Operation.php @@ -68,7 +68,7 @@ protected static function executeOperation(...$args): Result /** * Send an operation through the client and return the response. * - * @param array $args + * @param array $args */ protected static function fetchResponse(array $args): Response { @@ -87,7 +87,7 @@ protected static function fetchResponse(array $args): Response return $response; } - /** @param array $args */ + /** @param array $args */ protected static function variables(array $args): \stdClass { $variables = new \stdClass(); diff --git a/src/Testing/ClearsSailorClients.php b/src/Testing/ClearsSailorClients.php index 13bbc92..db0ce3b 100644 --- a/src/Testing/ClearsSailorClients.php +++ b/src/Testing/ClearsSailorClients.php @@ -2,11 +2,13 @@ namespace Spawnia\Sailor\Testing; +use PHPUnit\Framework\Attributes\After; use Spawnia\Sailor\Operation; trait ClearsSailorClients { /** @after */ + #[After] protected function tearDownSailorClients(): void { Operation::clearClients(); diff --git a/src/Testing/UsesSailorMocks.php b/src/Testing/UsesSailorMocks.php index 9619ea1..935e456 100644 --- a/src/Testing/UsesSailorMocks.php +++ b/src/Testing/UsesSailorMocks.php @@ -2,11 +2,13 @@ namespace Spawnia\Sailor\Testing; +use PHPUnit\Framework\Attributes\After; use Spawnia\Sailor\Operation; trait UsesSailorMocks { /** @after */ + #[After] protected function tearDownSailorMocks(): void { Operation::clearMocks(); diff --git a/tests/Unit/IntrospectorTest.php b/tests/Unit/IntrospectorTest.php index cb33ec9..c9bfb67 100644 --- a/tests/Unit/IntrospectorTest.php +++ b/tests/Unit/IntrospectorTest.php @@ -56,7 +56,7 @@ public function testFailsIntrospectionIfFallbackAlsoThrows(): void } /** @return iterable */ - public function validRequests(): iterable + public static function validRequests(): iterable { yield [ static fn (): Response => self::successfulIntrospectionMock(), diff --git a/tests/Unit/ResultTest.php b/tests/Unit/ResultTest.php index 850e01d..4231992 100644 --- a/tests/Unit/ResultTest.php +++ b/tests/Unit/ResultTest.php @@ -41,7 +41,7 @@ public function testThrowErrors(bool $isClientSafe): void } /** @return iterable */ - public function isClientSafe(): iterable + public static function isClientSafe(): iterable { yield [true]; yield [false];