diff --git a/.circleci/config.yml b/.circleci/config.yml index 66cc761..0a1f5bb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: parameters: php-version: type: string - default: "8.1" + default: "8.2" executor: name: php/php php-version: << parameters.php-version >> @@ -25,7 +25,7 @@ jobs: parameters: php-version: type: string - default: "8.1" + default: "8.2" executor: name: php/php php-version: << parameters.php-version >> @@ -50,12 +50,12 @@ workflows: php-version: <> matrix: parameters: - php-version: [ "8.1", "8.2", "8.3", "8.4" ] + php-version: [ "8.2", "8.3", "8.4" ] - codesniffer: matrix: parameters: - php-version: [ "8.1", "8.2", "8.3", "8.4" ] + php-version: [ "8.2", "8.3", "8.4" ] - cs-fixer: matrix: parameters: - php-version: [ "8.1", "8.2", "8.3" ] + php-version: [ "8.2", "8.3" ] diff --git a/composer.json b/composer.json index 263b01b..de71c35 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^11.0", "squizlabs/php_codesniffer": "3.*", "phpspec/prophecy-phpunit": "^2.0" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d91d7c3..850f0f2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,21 +2,27 @@ - + ./src + + diff --git a/src/Grphp/Client/Error/Status.php b/src/Grphp/Client/Error/Status.php index 5696230..3d55476 100644 --- a/src/Grphp/Client/Error/Status.php +++ b/src/Grphp/Client/Error/Status.php @@ -91,7 +91,7 @@ public static function getStatusCodeString(int $number): string /** * @param int $code * @param string $details - * @param HeaderCollection $headers + * @param ?HeaderCollection $headers */ public function __construct(int $code, string $details, ?HeaderCollection $headers = null) { diff --git a/tests/Unit/Grphp/Authentication/BasicTest.php b/tests/Unit/Grphp/Authentication/BasicTest.php index ca5291b..6f0f44f 100644 --- a/tests/Unit/Grphp/Authentication/BasicTest.php +++ b/tests/Unit/Grphp/Authentication/BasicTest.php @@ -17,20 +17,19 @@ */ namespace Grphp\Authentication; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; final class BasicTest extends TestCase { - /** - * @dataProvider providerGetMetadata - * @param array $options - */ + #[DataProvider('providerGetMetadata')] public function testGetMetadata(array $options = [], array $expected = []) { $auth = new Basic($options); $this->assertEquals($expected, $auth->getMetadata()); } - public function providerGetMetadata() + + public static function providerGetMetadata() { return [ [ // no options @@ -39,14 +38,14 @@ public function providerGetMetadata() ], [ // password only ['password' => 'foo'], - ['authorization' => [$this->encode('foo')]], + ['authorization' => [self::encode('foo')]], ], [ // username + password [ 'username' => 'foo', 'password' => 'bar', ], - ['authorization' => [$this->encode('foo:bar')]], + ['authorization' => [self::encode('foo:bar')]], ], [ // custom metadata key [ @@ -54,16 +53,16 @@ public function providerGetMetadata() 'password' => 'bar', 'metadata_key' => 'baz', ], - ['baz' => [$this->encode('foo:bar')]], + ['baz' => [self::encode('foo:bar')]], ] ]; } - /**] + /** * @param string $str * @return string */ - private function encode(string $str) + private static function encode(string $str) { $s = base64_encode($str); return "Basic $s"; diff --git a/tests/Unit/Grphp/Client/HeaderRegistryTest.php b/tests/Unit/Grphp/Client/HeaderCollectionTest.php similarity index 100% rename from tests/Unit/Grphp/Client/HeaderRegistryTest.php rename to tests/Unit/Grphp/Client/HeaderCollectionTest.php diff --git a/tests/Unit/Grphp/Client/Interceptors/LinkerD/ContextPropagationTest.php b/tests/Unit/Grphp/Client/Interceptors/LinkerD/ContextPropagationTest.php index 73c57d4..a0c135b 100644 --- a/tests/Unit/Grphp/Client/Interceptors/LinkerD/ContextPropagationTest.php +++ b/tests/Unit/Grphp/Client/Interceptors/LinkerD/ContextPropagationTest.php @@ -23,6 +23,7 @@ use Grphp\Client\HeaderCollection; use Grphp\Client\Response; use Grphp\Test\GetThingResp; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Grphp\Client\Interceptors\Base; @@ -42,8 +43,8 @@ protected function setUp(): void * @param string $incomingKey * @param string $metadataKey * @param string $value - * @dataProvider providerMetadataInServer */ + #[DataProvider('providerMetadataInServer')] public function testMetadataInServer($incomingKey, $metadataKey, $value) { $_SERVER[$incomingKey] = $value; @@ -51,7 +52,8 @@ public function testMetadataInServer($incomingKey, $metadataKey, $value) $interceptorMetadata = $this->interceptor->getMetadata(); $this->assertEquals($value, $interceptorMetadata[$metadataKey][0]); } - public function providerMetadataInServer() + + public static function providerMetadataInServer() { $data = []; foreach (ContextPropagation::METADATA_KEYS as $k => $v) { @@ -64,8 +66,8 @@ public function providerMetadataInServer() * @param string $incomingKey * @param string $metadataKey * @param string $value - * @dataProvider providerMetadataInRequest */ + #[DataProvider('providerMetadataInRequest')] public function testMetadataInRequest($incomingKey, $metadataKey, $value) { $_REQUEST[$incomingKey] = $value; @@ -73,7 +75,8 @@ public function testMetadataInRequest($incomingKey, $metadataKey, $value) $interceptorMetadata = $this->interceptor->getMetadata(); $this->assertEquals($value, $interceptorMetadata[$metadataKey][0]); } - public function providerMetadataInRequest() + + public static function providerMetadataInRequest() { $data = []; foreach (ContextPropagation::METADATA_KEYS as $k => $v) { @@ -87,8 +90,8 @@ public function providerMetadataInRequest() * @param string $metadataKey * @param string $serverValue * @param string $requestValue - * @dataProvider providerMetadataPrecedence */ + #[DataProvider('providerMetadataPrecedence')] public function testMetadataPrecedence($incomingKey, $metadataKey, $serverValue, $requestValue) { $_SERVER[$incomingKey] = $serverValue; @@ -97,7 +100,8 @@ public function testMetadataPrecedence($incomingKey, $metadataKey, $serverValue, $interceptorMetadata = $this->interceptor->getMetadata(); $this->assertEquals($requestValue, $interceptorMetadata[$metadataKey][0]); } - public function providerMetadataPrecedence() + + public static function providerMetadataPrecedence() { $data = []; foreach (ContextPropagation::METADATA_KEYS as $k => $v) { diff --git a/tests/Unit/Grphp/ClientTest.php b/tests/Unit/Grphp/ClientTest.php index b1b9028..1fc2f8e 100644 --- a/tests/Unit/Grphp/ClientTest.php +++ b/tests/Unit/Grphp/ClientTest.php @@ -23,6 +23,8 @@ use Grphp\Client\Error; use Grphp\Client\Interceptors\Base as BaseInterceptor; use Grphp\Client\Response; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; @@ -70,10 +72,8 @@ public function testAddInterceptor() $this->assertContains($interceptorMock, $this->client->getInterceptors()); } - /** - * @depends testClearInterceptors - * @depends testAddInterceptor - */ + #[Depends('testClearInterceptors')] + #[Depends('testAddInterceptor')] public function testGetInterceptors() { $this->client->clearInterceptors(); @@ -86,9 +86,8 @@ public function testGetInterceptors() /** * Test the call method - * - * @dataProvider providerCall */ + #[DataProvider('providerCall')] public function testCall($id, $isSuccess = true, $responseCode = 0, $responseDetails = '', $responseMetadata = []) { $opts = [ @@ -116,7 +115,7 @@ public function testCall($id, $isSuccess = true, $responseCode = 0, $responseDet $this->assertEquals('Foo', $thing->getName()); } - public function providerCall() + public static function providerCall() { return [ [123, true, 0, 'Whoa now', ['one' => ['two']]], diff --git a/tests/Unit/Grphp/Serializers/Errors/JsonTest.php b/tests/Unit/Grphp/Serializers/Errors/JsonTest.php index 297ac62..ce1381c 100644 --- a/tests/Unit/Grphp/Serializers/Errors/JsonTest.php +++ b/tests/Unit/Grphp/Serializers/Errors/JsonTest.php @@ -17,6 +17,7 @@ */ namespace Grphp\Serializers\Errors; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; final class JsonTest extends TestCase @@ -32,16 +33,17 @@ protected function setUp(): void } /** - * @dataProvider providerDeserialize * @param string $input * @param array $output */ + #[DataProvider('providerDeserialize')] public function testDeserialize(string $input, array $output = []) { $o = $this->serializer->deserialize($input); $this->assertEquals($output, $o); } - public function providerDeserialize() + + public static function providerDeserialize() { return [ ['{"foo":123,"bar":"go!"}',['foo' => 123,'bar' => 'go!']],