Skip to content

Commit

Permalink
Merge pull request #86 from php-http/guzzle-psr-integration
Browse files Browse the repository at this point in the history
re-enable and fix tests for guzzle integration
  • Loading branch information
dbu authored Mar 3, 2024
2 parents 81e5ef0 + 852c143 commit ae94cb9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/Build-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

<testsuite name="All">
<directory>tests</directory>
<!-- Exclude till https://github.com/php-http/message/issues/105 resolved. -->
<exclude>tests/Functional/HttpAsyncClientGuzzleTest.php</exclude>
<exclude>tests/Functional/HttpClientGuzzleTest.php</exclude>
</testsuite>

<testsuite name="Unit">
Expand All @@ -25,9 +22,6 @@

<testsuite name="Functional">
<directory>tests/Functional</directory>
<!-- Exclude till https://github.com/php-http/message/issues/105 resolved. -->
<exclude>tests/Functional/HttpAsyncClientGuzzleTest.php</exclude>
<exclude>tests/Functional/HttpClientGuzzleTest.php</exclude>
</testsuite>

</testsuites>
Expand Down
5 changes: 2 additions & 3 deletions tests/Functional/HttpAsyncClientGuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
}
}
9 changes: 4 additions & 5 deletions tests/Functional/HttpClientGuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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());
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'
);
}

Expand All @@ -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, []);
Expand Down

0 comments on commit ae94cb9

Please sign in to comment.