From 42519170a20c3c15784e099cd196c77be4ce84fb Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 10:03:59 +0100 Subject: [PATCH 01/12] feat: allow PHPUnit 10-12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 25ea7b6..bee01df 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpunit/phpunit": "^9.6.17", + "phpunit/phpunit": "^9.6.29 || ^10.5.58 || ^11.5.43 || ^12.4.2", "php-http/message": "^1.0 || ^2.0", "php-http/message-factory": "^1.0", "guzzlehttp/psr7": "^1.9 || ^2.0", From 26bc3fa5342ac7bb1a6996c4df43f379aff820f7 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 10:08:54 +0100 Subject: [PATCH 02/12] feat: allow PHPUnit 10-11 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bee01df..ab5cd87 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpunit/phpunit": "^9.6.29 || ^10.5.58 || ^11.5.43 || ^12.4.2", + "phpunit/phpunit": "^9.6.29 || ^10.5.58 || ^11.5.43", "php-http/message": "^1.0 || ^2.0", "php-http/message-factory": "^1.0", "guzzlehttp/psr7": "^1.9 || ^2.0", From 78771ba77a576b5dffb9b5956628efc224ae45cf Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 11 Nov 2025 10:21:15 +0100 Subject: [PATCH 03/12] Update composer.json Co-authored-by: David Buchmann --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ab5cd87..c7aca90 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpunit/phpunit": "^9.6.29 || ^10.5.58 || ^11.5.43", + "phpunit/phpunit": "^9.6.17 || ^10.0 || ^11.0", "php-http/message": "^1.0 || ^2.0", "php-http/message-factory": "^1.0", "guzzlehttp/psr7": "^1.9 || ^2.0", From 2379acf677e69dfa0d9007dc10c30f9b70ea25bd Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 10:27:14 +0100 Subject: [PATCH 04/12] feat: allow PHPUnit 10-11 --- .github/workflows/ci.yml | 2 +- .github/workflows/static.yml | 2 +- src/HttpBaseTest.php | 2 +- src/HttpFeatureTest.php | 6 +++--- src/PhpUnitBackwardCompatibleTrait.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c3515a..c826368 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: tools: composer:v2 - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Download dependencies run: | diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index f9635cd..75f222d 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: PHP-CS-Fixer uses: docker://oskarstark/php-cs-fixer-ga:2.16.4 diff --git a/src/HttpBaseTest.php b/src/HttpBaseTest.php index cbf7a4f..2cae305 100644 --- a/src/HttpBaseTest.php +++ b/src/HttpBaseTest.php @@ -223,7 +223,7 @@ protected function assertResponse(ResponseInterface $response, array $options = if (null === $options['body']) { $this->assertEmpty($response->getBody()->__toString()); } else { - $this->assertStringContainsString($options['body'], $response->getBody()->__toString()); + $this->assertStringContainsStringCompatible($options['body'], $response->getBody()->__toString()); } } diff --git a/src/HttpFeatureTest.php b/src/HttpFeatureTest.php index a8faf33..d8b3c14 100644 --- a/src/HttpFeatureTest.php +++ b/src/HttpFeatureTest.php @@ -143,7 +143,7 @@ public function testEncoding() $response = $this->createClient()->sendRequest($request); $this->assertSame(200, $response->getStatusCode()); - $this->assertStringContainsString('€', $response->getBody()->__toString()); + $this->assertStringContainsStringCompatible('€', $response->getBody()->__toString()); } /** @@ -159,7 +159,7 @@ public function testGzip() $response = $this->createClient()->sendRequest($request); $this->assertSame(200, $response->getStatusCode()); - $this->assertStringContainsString('gzip', $response->getBody()->__toString()); + $this->assertStringContainsStringCompatible('gzip', $response->getBody()->__toString()); } /** @@ -175,7 +175,7 @@ public function testDeflate() $response = $this->createClient()->sendRequest($request); $this->assertSame(200, $response->getStatusCode()); - $this->assertStringContainsString('deflate', $response->getBody()->__toString()); + $this->assertStringContainsStringCompatible('deflate', $response->getBody()->__toString()); } /** diff --git a/src/PhpUnitBackwardCompatibleTrait.php b/src/PhpUnitBackwardCompatibleTrait.php index 05f094d..ac71f2e 100644 --- a/src/PhpUnitBackwardCompatibleTrait.php +++ b/src/PhpUnitBackwardCompatibleTrait.php @@ -6,7 +6,7 @@ trait PhpUnitBackwardCompatibleTrait { - public static function assertStringContainsString(string $needle, string $haystack, string $message = ''): void + public static function assertStringContainsStringCompatible(string $needle, string $haystack, string $message = ''): void { // For supporting both phpunit 7 and 8 without display any deprecation. if (method_exists(TestCase::class, 'assertStringContainsString')) { From dc1e28178ac03290abbcc6c52fa43e5d2fbb56e7 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 10:36:51 +0100 Subject: [PATCH 05/12] feat: allow PHPUnit 10-11 --- src/HttpAsyncClientTest.php | 9 ++++++++- src/HttpBaseTest.php | 20 ++++++++++---------- src/HttpClientTest.php | 7 +++++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/HttpAsyncClientTest.php b/src/HttpAsyncClientTest.php index 0f13c05..a0092fa 100644 --- a/src/HttpAsyncClientTest.php +++ b/src/HttpAsyncClientTest.php @@ -3,6 +3,8 @@ namespace Http\Client\Tests; use Http\Client\HttpAsyncClient; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; abstract class HttpAsyncClientTest extends HttpBaseTest { @@ -90,6 +92,8 @@ public function testSuccessiveInvalidCallMustUseException() * @dataProvider requestProvider * @group integration */ + #[DataProvider('requestProvider')] + #[Group('integration')] public function testAsyncSendRequest($method, $uri, array $headers, $body) { if (null != $body) { @@ -124,8 +128,9 @@ public function testAsyncSendRequest($method, $uri, array $headers, $body) } /** - * @group integration + * @group integration */ + #[Group('integration')] public function testSendAsyncWithInvalidUri() { $request = self::$messageFactory->createRequest( @@ -159,6 +164,8 @@ public function testSendAsyncWithInvalidUri() * @dataProvider requestWithOutcomeProvider * @group integration */ + #[Group('integration')] + #[DataProvider('requestWithOutcomeProvider')] public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion, array $headers, $body) { if ('1.0' === $protocolVersion) { diff --git a/src/HttpBaseTest.php b/src/HttpBaseTest.php index 2cae305..030200f 100644 --- a/src/HttpBaseTest.php +++ b/src/HttpBaseTest.php @@ -61,13 +61,13 @@ public static function tearDownAfterClass(): void } } - public function requestProvider(): array + public static function requestProvider(): array { $sets = [ - 'methods' => $this->getMethods(), - 'uris' => [$this->getUri()], - 'headers' => $this->getHeaders(), - 'body' => $this->getBodies(), + 'methods' => self::getMethods(), + 'uris' => [self::getUri()], + 'headers' => self::getHeaders(), + 'body' => self::getBodies(), ]; $cartesianProduct = new CartesianProduct($sets); @@ -84,13 +84,13 @@ public function requestProvider(): array }); } - public function requestWithOutcomeProvider(): array + public static function requestWithOutcomeProvider(): array { $sets = [ - 'urisAndOutcomes' => $this->getUrisAndOutcomes(), - 'protocolVersions' => $this->getProtocolVersions(), - 'headers' => $this->getHeaders(), - 'body' => $this->getBodies(), + 'urisAndOutcomes' => self::getUrisAndOutcomes(), + 'protocolVersions' => self::getProtocolVersions(), + 'headers' => self::getHeaders(), + 'body' => self::getBodies(), ]; $cartesianProduct = new CartesianProduct($sets); diff --git a/src/HttpClientTest.php b/src/HttpClientTest.php index aaaf7a4..c1bd1a6 100644 --- a/src/HttpClientTest.php +++ b/src/HttpClientTest.php @@ -2,6 +2,8 @@ namespace Http\Client\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Psr\Http\Client\ClientInterface; use Psr\Http\Client\NetworkExceptionInterface; @@ -37,6 +39,8 @@ abstract protected function createHttpAdapter(): ClientInterface; * @dataProvider requestProvider * @group integration */ + #[Group('integration')] + #[DataProvider('requestProvider')] public function testSendRequest($method, $uri, array $headers, $body) { if (null != $body) { @@ -65,6 +69,8 @@ public function testSendRequest($method, $uri, array $headers, $body) * @dataProvider requestWithOutcomeProvider * @group integration */ + #[Group('integration')] + #[DataProvider('requestWithOutcomeProvider')] public function testSendRequestWithOutcome($uriAndOutcome, $protocolVersion, array $headers, $body) { if ('1.0' === $protocolVersion) { @@ -95,6 +101,7 @@ public function testSendRequestWithOutcome($uriAndOutcome, $protocolVersion, arr /** * @group integration */ + #[Group('integration')] public function testSendWithInvalidUri() { $request = self::$messageFactory->createRequest( From bc32889192f724ce80ca7f2f1b9f3e28ac5ddb30 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 10:49:03 +0100 Subject: [PATCH 06/12] feat: allow PHPUnit 10-11 --- src/HttpBaseTest.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/HttpBaseTest.php b/src/HttpBaseTest.php index 030200f..49380b3 100644 --- a/src/HttpBaseTest.php +++ b/src/HttpBaseTest.php @@ -36,7 +36,7 @@ abstract class HttpBaseTest extends TestCase /** * @var array */ - protected $defaultHeaders = [ + protected static $defaultHeaders = [ 'Connection' => 'close', 'User-Agent' => 'PHP HTTP Adapter', 'Content-Length' => '0', @@ -98,7 +98,7 @@ public static function requestWithOutcomeProvider(): array return $cartesianProduct->compute(); } - private function getMethods(): array + private static function getMethods(): array { return [ 'GET', @@ -116,7 +116,7 @@ private function getMethods(): array * * @return string|null */ - protected function getUri(array $query = []) + protected static function getUri(array $query = []) { return !empty($query) ? PHPUnitUtility::getUri().'?'.http_build_query($query, '', '&') @@ -134,25 +134,25 @@ protected function getInvalidUri() /** * @return array */ - private function getUrisAndOutcomes() + private static function getUrisAndOutcomes() { return [ [ - $this->getUri(['client_error' => true]), + self::getUri(['client_error' => true]), [ 'statusCode' => 400, 'reasonPhrase' => 'Bad Request', ], ], [ - $this->getUri(['server_error' => true]), + self::getUri(['server_error' => true]), [ 'statusCode' => 500, 'reasonPhrase' => 'Internal Server Error', ], ], [ - $this->getUri(['redirect' => true]), + self::getUri(['redirect' => true]), [ 'statusCode' => 302, 'reasonPhrase' => 'Found', @@ -165,7 +165,7 @@ private function getUrisAndOutcomes() /** * @return array */ - private function getProtocolVersions() + private static function getProtocolVersions() { return ['1.1', '1.0']; } @@ -173,14 +173,14 @@ private function getProtocolVersions() /** * @return string[] */ - private function getHeaders() + private static function getHeaders() { - $headers = $this->defaultHeaders; + $headers = self::$defaultHeaders; $headers['Accept-Charset'] = 'utf-8'; $headers['Accept-Language'] = 'en'; return [ - $this->defaultHeaders, + self::$defaultHeaders, $headers, ]; } @@ -188,18 +188,18 @@ private function getHeaders() /** * @return array */ - private function getBodies() + private static function getBodies() { return [ null, - http_build_query($this->getData(), '', '&'), + http_build_query(self::getData(), '', '&'), ]; } /** * @return array */ - private function getData() + private static function getData() { return ['param1' => 'foo', 'param2' => ['bar', ['baz']]]; } @@ -223,7 +223,7 @@ protected function assertResponse(ResponseInterface $response, array $options = if (null === $options['body']) { $this->assertEmpty($response->getBody()->__toString()); } else { - $this->assertStringContainsStringCompatible($options['body'], $response->getBody()->__toString()); + self::assertStringContainsStringCompatible($options['body'], $response->getBody()->__toString()); } } From 33627e15109ed7e7e2e592bb9e61ca245bdd03d3 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 10:53:40 +0100 Subject: [PATCH 07/12] feat: allow PHPUnit 10-11 --- src/HttpClientTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HttpClientTest.php b/src/HttpClientTest.php index c1bd1a6..884a319 100644 --- a/src/HttpClientTest.php +++ b/src/HttpClientTest.php @@ -107,7 +107,7 @@ public function testSendWithInvalidUri() $request = self::$messageFactory->createRequest( 'GET', $this->getInvalidUri(), - $this->defaultHeaders + self::$defaultHeaders ); $this->expectException(NetworkExceptionInterface::class); From 68b8f6127a189d3c523ca0fc0764955e410017df Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 10:59:02 +0100 Subject: [PATCH 08/12] feat: allow PHPUnit 10-11 --- src/HttpAsyncClientTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HttpAsyncClientTest.php b/src/HttpAsyncClientTest.php index a0092fa..1301ff6 100644 --- a/src/HttpAsyncClientTest.php +++ b/src/HttpAsyncClientTest.php @@ -35,8 +35,8 @@ public function testSuccessiveCallMustUseResponseInterface() { $request = self::$messageFactory->createRequest( 'GET', - $this->getUri(), - $this->defaultHeaders + self::getUri(), + self::$defaultHeaders ); $promise = $this->httpAsyncClient->sendAsyncRequest($request); @@ -63,7 +63,7 @@ public function testSuccessiveInvalidCallMustUseException() $request = self::$messageFactory->createRequest( 'GET', $this->getInvalidUri(), - $this->defaultHeaders + self::$defaultHeaders ); $promise = $this->httpAsyncClient->sendAsyncRequest($request); @@ -136,7 +136,7 @@ public function testSendAsyncWithInvalidUri() $request = self::$messageFactory->createRequest( 'GET', $this->getInvalidUri(), - $this->defaultHeaders + self::$defaultHeaders ); $exception = null; From 617fdbe3474c2a3cfe4c152c1d5b7c58c4825dd5 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 11:02:45 +0100 Subject: [PATCH 09/12] feat: allow PHPUnit 10-12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c7aca90..784d11f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpunit/phpunit": "^9.6.17 || ^10.0 || ^11.0", + "phpunit/phpunit": "^9.6.17 || ^10.0 || ^11.0 || ^12.0", "php-http/message": "^1.0 || ^2.0", "php-http/message-factory": "^1.0", "guzzlehttp/psr7": "^1.9 || ^2.0", From 9203935cc0275ad5e0ae2129839ad3ccecb78868 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Tue, 11 Nov 2025 11:36:51 +0100 Subject: [PATCH 10/12] feat: allow PHPUnit 10-12 --- CHANGELOG.md | 6 ++++++ src/HttpBaseTest.php | 4 +--- src/HttpFeatureTest.php | 8 +++----- src/PhpUnitBackwardCompatibleTrait.php | 18 ------------------ 4 files changed, 10 insertions(+), 26 deletions(-) delete mode 100644 src/PhpUnitBackwardCompatibleTrait.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d08045..617033d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [3.1.2] - 2025-11-11 + +- Allow PHPUnit > 9 +- Removed PhpUnitBackwardCompatibleTrait + ## [3.1.1] - 2024-09-01 - Switched to `httpbin.org` for tests now that its fixed. (Reverts [#56](https://github.com/php-http/client-integration-tests/pull/56)) diff --git a/src/HttpBaseTest.php b/src/HttpBaseTest.php index 49380b3..e735126 100644 --- a/src/HttpBaseTest.php +++ b/src/HttpBaseTest.php @@ -10,8 +10,6 @@ abstract class HttpBaseTest extends TestCase { - use PhpUnitBackwardCompatibleTrait; - /** * @var string */ @@ -223,7 +221,7 @@ protected function assertResponse(ResponseInterface $response, array $options = if (null === $options['body']) { $this->assertEmpty($response->getBody()->__toString()); } else { - self::assertStringContainsStringCompatible($options['body'], $response->getBody()->__toString()); + self::assertStringContainsString($options['body'], $response->getBody()->__toString()); } } diff --git a/src/HttpFeatureTest.php b/src/HttpFeatureTest.php index d8b3c14..7823ffd 100644 --- a/src/HttpFeatureTest.php +++ b/src/HttpFeatureTest.php @@ -9,8 +9,6 @@ abstract class HttpFeatureTest extends TestCase { - use PhpUnitBackwardCompatibleTrait; - /** * @var MessageFactory */ @@ -143,7 +141,7 @@ public function testEncoding() $response = $this->createClient()->sendRequest($request); $this->assertSame(200, $response->getStatusCode()); - $this->assertStringContainsStringCompatible('€', $response->getBody()->__toString()); + $this->assertStringContainsString('€', $response->getBody()->__toString()); } /** @@ -159,7 +157,7 @@ public function testGzip() $response = $this->createClient()->sendRequest($request); $this->assertSame(200, $response->getStatusCode()); - $this->assertStringContainsStringCompatible('gzip', $response->getBody()->__toString()); + $this->assertStringContainsString('gzip', $response->getBody()->__toString()); } /** @@ -175,7 +173,7 @@ public function testDeflate() $response = $this->createClient()->sendRequest($request); $this->assertSame(200, $response->getStatusCode()); - $this->assertStringContainsStringCompatible('deflate', $response->getBody()->__toString()); + $this->assertStringContainsString('deflate', $response->getBody()->__toString()); } /** diff --git a/src/PhpUnitBackwardCompatibleTrait.php b/src/PhpUnitBackwardCompatibleTrait.php deleted file mode 100644 index ac71f2e..0000000 --- a/src/PhpUnitBackwardCompatibleTrait.php +++ /dev/null @@ -1,18 +0,0 @@ - Date: Tue, 11 Nov 2025 11:39:29 +0100 Subject: [PATCH 11/12] feat: allow PHPUnit 10-12 --- CHANGELOG.md | 2 +- src/PhpUnitBackwardCompatibleTrait.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/PhpUnitBackwardCompatibleTrait.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 617033d..030cae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [3.1.2] - 2025-11-11 - Allow PHPUnit > 9 -- Removed PhpUnitBackwardCompatibleTrait +- Deprecate PhpUnitBackwardCompatibleTrait ## [3.1.1] - 2024-09-01 diff --git a/src/PhpUnitBackwardCompatibleTrait.php b/src/PhpUnitBackwardCompatibleTrait.php new file mode 100644 index 0000000..08ae87f --- /dev/null +++ b/src/PhpUnitBackwardCompatibleTrait.php @@ -0,0 +1,21 @@ + Date: Tue, 11 Nov 2025 13:20:19 +0100 Subject: [PATCH 12/12] Update src/PhpUnitBackwardCompatibleTrait.php --- src/PhpUnitBackwardCompatibleTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpUnitBackwardCompatibleTrait.php b/src/PhpUnitBackwardCompatibleTrait.php index 08ae87f..89380a9 100644 --- a/src/PhpUnitBackwardCompatibleTrait.php +++ b/src/PhpUnitBackwardCompatibleTrait.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** - * @deprecated + * @deprecated this trait was to help using phpunit 7 and 8 which are obsolete. this trait will be removed in the next major version. */ trait PhpUnitBackwardCompatibleTrait {