Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable and fix tests for guzzle integration #86

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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