Skip to content

Commit 852c143

Browse files
committed
re-enable and fix tests for guzzle integration
1 parent 81e5ef0 commit 852c143

File tree

6 files changed

+15
-23
lines changed

6 files changed

+15
-23
lines changed

.github/workflows/Build-Test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
operating-system: [ubuntu-22.04]
18-
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
18+
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3']
1919
include:
2020
- operating-system: ubuntu-20.04
21-
php-versions: '7.1'
21+
php-versions: '7.4'
2222
COMPOSER_FLAGS: '--prefer-stable --prefer-lowest'
2323
PHPUNIT_FLAGS: '--coverage-clover build/coverage.xml'
2424

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"prefer-stable": true,
1616
"minimum-stability": "dev",
1717
"require": {
18-
"php": "^7.1 || ^8.0",
18+
"php": "^7.4 || ^8.0",
1919
"ext-curl": "*",
2020
"php-http/discovery": "^1.6",
2121
"php-http/httplug": "^2.0",
@@ -25,7 +25,7 @@
2525
"symfony/options-resolver": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0"
2626
},
2727
"require-dev": {
28-
"guzzlehttp/psr7": "^1.0",
28+
"guzzlehttp/psr7": "^2.0",
2929
"php-http/client-integration-tests": "^3.0",
3030
"phpunit/phpunit": "^7.5 || ^9.4",
3131
"laminas/laminas-diactoros": "^2.0",

phpunit.xml.dist

-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

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

2219
<testsuite name="Unit">
@@ -25,9 +22,6 @@
2522

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

3327
</testsuites>

tests/Functional/HttpAsyncClientGuzzleTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
namespace Http\Client\Curl\Tests\Functional;
66

7+
use GuzzleHttp\Psr7\HttpFactory;
78
use Http\Client\Curl\Client;
89
use Http\Client\HttpAsyncClient;
9-
use Http\Message\MessageFactory\GuzzleMessageFactory;
10-
use Http\Message\StreamFactory\GuzzleStreamFactory;
1110

1211
/**
1312
* @covers \Http\Client\Curl\Client
@@ -19,6 +18,6 @@ class HttpAsyncClientGuzzleTest extends HttpAsyncClientTestCase
1918
*/
2019
protected function createHttpAsyncClient(): HttpAsyncClient
2120
{
22-
return new Client(new GuzzleMessageFactory(), new GuzzleStreamFactory());
21+
return new Client(new HttpFactory(), new HttpFactory());
2322
}
2423
}

tests/Functional/HttpClientGuzzleTest.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace Http\Client\Curl\Tests\Functional;
66

7+
use GuzzleHttp\Psr7\HttpFactory;
78
use GuzzleHttp\Psr7\Stream;
89
use Http\Client\Curl\Client;
9-
use Http\Client\HttpClient;
10-
use Http\Message\MessageFactory\GuzzleMessageFactory;
11-
use Http\Message\StreamFactory\GuzzleStreamFactory;
10+
use Psr\Http\Client\ClientInterface;
1211
use Psr\Http\Message\StreamInterface;
1312

1413
/**
@@ -19,9 +18,9 @@ class HttpClientGuzzleTest extends HttpClientTestCase
1918
/**
2019
* {@inheritdoc}
2120
*/
22-
protected function createHttpAdapter(): HttpClient
21+
protected function createHttpAdapter(): ClientInterface
2322
{
24-
return new Client(new GuzzleMessageFactory(), new GuzzleStreamFactory());
23+
return new Client(new HttpFactory(), new HttpFactory());
2524
}
2625

2726
/**

tests/Unit/ClientTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Http\Client\Curl\Tests\Unit;
66

7+
use GuzzleHttp\Psr7\Utils;
78
use Http\Client\Curl\Client;
89
use PHPUnit\Framework\TestCase;
910
use Psr\Http\Message\ResponseFactoryInterface;
@@ -83,14 +84,13 @@ public function testRewindLargeStream(): void
8384
}
8485

8586
$length = strlen($content);
86-
$body = \GuzzleHttp\Psr7\stream_for($content);
87+
$body = Utils::streamFor($content);
8788
$body->seek(40);
8889
$request = new Request('http://foo.com', 'POST', $body);
8990
$options = $bodyOptions->invoke($client, $request, []);
9091

91-
static::assertTrue(
92-
false !== strstr($options[CURLOPT_READFUNCTION](null, null, $length), 'abcdef'),
93-
'Steam was not rewinded'
92+
static::assertNotFalse(
93+
strpos($options[CURLOPT_READFUNCTION](null, null, $length), 'abcdef'), 'Steam was not rewinded'
9494
);
9595
}
9696

@@ -101,7 +101,7 @@ public function testRewindStream(): void
101101
$bodyOptions = new \ReflectionMethod(Client::class, 'addRequestBodyOptions');
102102
$bodyOptions->setAccessible(true);
103103

104-
$body = \GuzzleHttp\Psr7\stream_for('abcdef');
104+
$body = Utils::streamFor('abcdef');
105105
$body->seek(3);
106106
$request = new Request('http://foo.com', 'POST', $body);
107107
$options = $bodyOptions->invoke($client, $request, []);

0 commit comments

Comments
 (0)