Skip to content

Commit bae45f7

Browse files
authored
chore: bump psr/http-message requirement (#206)
* chore: bump psr/http-message requirement * fix return types
1 parent 20b87ae commit bae45f7

File tree

4 files changed

+37
-16
lines changed

4 files changed

+37
-16
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"kevinrob/guzzle-cache-middleware": "^5.0",
1717
"phpdocumentor/reflection-docblock": "^5.2",
1818
"propaganistas/laravel-phone": "^5.3",
19-
"psr/http-message": "^1.0",
19+
"psr/http-message": "^1.1|^2.0",
2020
"supportpal/eloquent-model": "^1.0",
2121
"symfony/config": "^6.2|^7.0",
2222
"symfony/dependency-injection": "^6.2|^7.0",

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/Unit/ApiClientTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Psr\Http\Client\ClientInterface;
1313
use Psr\Http\Message\RequestInterface;
1414
use Psr\Http\Message\ResponseInterface;
15+
use Psr\Http\Message\StreamInterface;
1516
use SupportPal\ApiClient\Exception\HttpResponseException;
1617
use SupportPal\ApiClient\Http\Client;
1718
use SupportPal\ApiClient\Http\CoreClient;
@@ -81,13 +82,17 @@ public function testResponseNonEncodeableException(): void
8182
$response = $this->prophesize(ResponseInterface::class);
8283
$response->getReasonPhrase()->shouldBeCalled()->willReturn('');
8384

84-
$this
85-
->httpClient
85+
$this->httpClient
8686
->sendRequest($request->reveal())
8787
->willReturn($response->reveal())
8888
->shouldBeCalled();
8989

90-
$response->getBody()->willReturn('');
90+
$streamProphecy = $this->prophesize(StreamInterface::class);
91+
$streamProphecy->__toString()
92+
->willReturn('')
93+
->shouldBeCalled();
94+
95+
$response->getBody()->willReturn($streamProphecy->reveal());
9196

9297
/** @var RequestInterface $requestMock */
9398
$requestMock = $request->reveal();
@@ -163,9 +168,14 @@ protected function sendRequestCommonExpectations(
163168
string $responseBody,
164169
ObjectProphecy $request
165170
): ObjectProphecy {
171+
$streamProphecy = $this->prophesize(StreamInterface::class);
172+
$streamProphecy->__toString()
173+
->willReturn($responseBody)
174+
->shouldBeCalled();
175+
166176
$response = $this->prophesize(ResponseInterface::class);
167177
$response->getStatusCode()->willReturn($statusCode);
168-
$response->getBody()->willReturn($responseBody);
178+
$response->getBody()->willReturn($streamProphecy->reveal());
169179
$this->httpClient->sendRequest($request->reveal())->shouldBeCalled()->willReturn($response->reveal());
170180

171181
return $response;

test/Unit/ApiTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Prophecy\Prophecy\ObjectProphecy;
66
use Psr\Http\Message\ResponseInterface;
7+
use Psr\Http\Message\StreamInterface;
78
use SupportPal\ApiClient\Api\Api;
89
use SupportPal\ApiClient\Http\Client;
910
use SupportPal\ApiClient\Model\Model;
@@ -42,9 +43,14 @@ protected function setUp(): void
4243
*/
4344
protected function makeCommonExpectations(array $responseData, string $model): array
4445
{
46+
$streamProphecy = $this->prophesize(StreamInterface::class);
47+
$streamProphecy->__toString()
48+
->willReturn(json_encode($responseData))
49+
->shouldBeCalled();
50+
4551
$response = $this->prophesize(ResponseInterface::class);
4652
$response->getBody()
47-
->willReturn(json_encode($responseData));
53+
->willReturn($streamProphecy->reveal());
4854

4955
if (is_array(current($responseData['data']))) {
5056
$models = [];
@@ -68,9 +74,14 @@ protected function makeCommonExpectations(array $responseData, string $model): a
6874
*/
6975
protected function makeSuccessResponse()
7076
{
77+
$streamProphecy = $this->prophesize(StreamInterface::class);
78+
$streamProphecy->__toString()
79+
->willReturn(json_encode(['status' => 'success']))
80+
->shouldBeCalled();
81+
7182
$response = $this->prophesize(ResponseInterface::class);
7283
$response->getBody()
73-
->willReturn(json_encode(['status' => 'success']));
84+
->willReturn($streamProphecy->reveal());
7485

7586
return $response;
7687
}

0 commit comments

Comments
 (0)