From 852c143927d5e05af11d09f751e2b3b92460a8a2 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 3 Mar 2024 09:14:19 +0100 Subject: [PATCH] re-enable and fix tests for guzzle integration --- .github/workflows/Build-Test.yml | 4 ++-- composer.json | 4 ++-- phpunit.xml.dist | 6 ------ tests/Functional/HttpAsyncClientGuzzleTest.php | 5 ++--- tests/Functional/HttpClientGuzzleTest.php | 9 ++++----- tests/Unit/ClientTest.php | 10 +++++----- 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/Build-Test.yml b/.github/workflows/Build-Test.yml index 337c785..991180c 100644 --- a/.github/workflows/Build-Test.yml +++ b/.github/workflows/Build-Test.yml @@ -15,10 +15,10 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-22.04] - php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3'] include: - operating-system: ubuntu-20.04 - php-versions: '7.1' + php-versions: '7.4' COMPOSER_FLAGS: '--prefer-stable --prefer-lowest' PHPUNIT_FLAGS: '--coverage-clover build/coverage.xml' diff --git a/composer.json b/composer.json index f332007..9b8cd08 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "prefer-stable": true, "minimum-stability": "dev", "require": { - "php": "^7.1 || ^8.0", + "php": "^7.4 || ^8.0", "ext-curl": "*", "php-http/discovery": "^1.6", "php-http/httplug": "^2.0", @@ -25,7 +25,7 @@ "symfony/options-resolver": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { - "guzzlehttp/psr7": "^1.0", + "guzzlehttp/psr7": "^2.0", "php-http/client-integration-tests": "^3.0", "phpunit/phpunit": "^7.5 || ^9.4", "laminas/laminas-diactoros": "^2.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3f3b615..1df4f8a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,9 +14,6 @@ tests - - tests/Functional/HttpAsyncClientGuzzleTest.php - tests/Functional/HttpClientGuzzleTest.php @@ -25,9 +22,6 @@ tests/Functional - - tests/Functional/HttpAsyncClientGuzzleTest.php - tests/Functional/HttpClientGuzzleTest.php diff --git a/tests/Functional/HttpAsyncClientGuzzleTest.php b/tests/Functional/HttpAsyncClientGuzzleTest.php index f1d2808..2f6c47f 100644 --- a/tests/Functional/HttpAsyncClientGuzzleTest.php +++ b/tests/Functional/HttpAsyncClientGuzzleTest.php @@ -4,10 +4,9 @@ namespace Http\Client\Curl\Tests\Functional; +use GuzzleHttp\Psr7\HttpFactory; use Http\Client\Curl\Client; use Http\Client\HttpAsyncClient; -use Http\Message\MessageFactory\GuzzleMessageFactory; -use Http\Message\StreamFactory\GuzzleStreamFactory; /** * @covers \Http\Client\Curl\Client @@ -19,6 +18,6 @@ class HttpAsyncClientGuzzleTest extends HttpAsyncClientTestCase */ protected function createHttpAsyncClient(): HttpAsyncClient { - return new Client(new GuzzleMessageFactory(), new GuzzleStreamFactory()); + return new Client(new HttpFactory(), new HttpFactory()); } } diff --git a/tests/Functional/HttpClientGuzzleTest.php b/tests/Functional/HttpClientGuzzleTest.php index 9cbe9da..d7cf853 100644 --- a/tests/Functional/HttpClientGuzzleTest.php +++ b/tests/Functional/HttpClientGuzzleTest.php @@ -4,11 +4,10 @@ namespace Http\Client\Curl\Tests\Functional; +use GuzzleHttp\Psr7\HttpFactory; use GuzzleHttp\Psr7\Stream; use Http\Client\Curl\Client; -use Http\Client\HttpClient; -use Http\Message\MessageFactory\GuzzleMessageFactory; -use Http\Message\StreamFactory\GuzzleStreamFactory; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\StreamInterface; /** @@ -19,9 +18,9 @@ class HttpClientGuzzleTest extends HttpClientTestCase /** * {@inheritdoc} */ - protected function createHttpAdapter(): HttpClient + protected function createHttpAdapter(): ClientInterface { - return new Client(new GuzzleMessageFactory(), new GuzzleStreamFactory()); + return new Client(new HttpFactory(), new HttpFactory()); } /** diff --git a/tests/Unit/ClientTest.php b/tests/Unit/ClientTest.php index f198930..55d3e89 100644 --- a/tests/Unit/ClientTest.php +++ b/tests/Unit/ClientTest.php @@ -4,6 +4,7 @@ namespace Http\Client\Curl\Tests\Unit; +use GuzzleHttp\Psr7\Utils; use Http\Client\Curl\Client; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseFactoryInterface; @@ -83,14 +84,13 @@ public function testRewindLargeStream(): void } $length = strlen($content); - $body = \GuzzleHttp\Psr7\stream_for($content); + $body = Utils::streamFor($content); $body->seek(40); $request = new Request('http://foo.com', 'POST', $body); $options = $bodyOptions->invoke($client, $request, []); - static::assertTrue( - false !== strstr($options[CURLOPT_READFUNCTION](null, null, $length), 'abcdef'), - 'Steam was not rewinded' + static::assertNotFalse( + strpos($options[CURLOPT_READFUNCTION](null, null, $length), 'abcdef'), 'Steam was not rewinded' ); } @@ -101,7 +101,7 @@ public function testRewindStream(): void $bodyOptions = new \ReflectionMethod(Client::class, 'addRequestBodyOptions'); $bodyOptions->setAccessible(true); - $body = \GuzzleHttp\Psr7\stream_for('abcdef'); + $body = Utils::streamFor('abcdef'); $body->seek(3); $request = new Request('http://foo.com', 'POST', $body); $options = $bodyOptions->invoke($client, $request, []);