Skip to content

Commit

Permalink
chore: bump psr/http-message requirement (#206)
Browse files Browse the repository at this point in the history
* chore: bump psr/http-message requirement

* fix return types
  • Loading branch information
jshah4517 authored Jul 9, 2024
1 parent 20b87ae commit bae45f7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"kevinrob/guzzle-cache-middleware": "^5.0",
"phpdocumentor/reflection-docblock": "^5.2",
"propaganistas/laravel-phone": "^5.3",
"psr/http-message": "^1.0",
"psr/http-message": "^1.1|^2.0",
"supportpal/eloquent-model": "^1.0",
"symfony/config": "^6.2|^7.0",
"symfony/dependency-injection": "^6.2|^7.0",
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions test/Unit/ApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use SupportPal\ApiClient\Exception\HttpResponseException;
use SupportPal\ApiClient\Http\Client;
use SupportPal\ApiClient\Http\CoreClient;
Expand Down Expand Up @@ -81,13 +82,17 @@ public function testResponseNonEncodeableException(): void
$response = $this->prophesize(ResponseInterface::class);
$response->getReasonPhrase()->shouldBeCalled()->willReturn('');

$this
->httpClient
$this->httpClient
->sendRequest($request->reveal())
->willReturn($response->reveal())
->shouldBeCalled();

$response->getBody()->willReturn('');
$streamProphecy = $this->prophesize(StreamInterface::class);
$streamProphecy->__toString()
->willReturn('')
->shouldBeCalled();

$response->getBody()->willReturn($streamProphecy->reveal());

/** @var RequestInterface $requestMock */
$requestMock = $request->reveal();
Expand Down Expand Up @@ -163,9 +168,14 @@ protected function sendRequestCommonExpectations(
string $responseBody,
ObjectProphecy $request
): ObjectProphecy {
$streamProphecy = $this->prophesize(StreamInterface::class);
$streamProphecy->__toString()
->willReturn($responseBody)
->shouldBeCalled();

$response = $this->prophesize(ResponseInterface::class);
$response->getStatusCode()->willReturn($statusCode);
$response->getBody()->willReturn($responseBody);
$response->getBody()->willReturn($streamProphecy->reveal());
$this->httpClient->sendRequest($request->reveal())->shouldBeCalled()->willReturn($response->reveal());

return $response;
Expand Down
15 changes: 13 additions & 2 deletions test/Unit/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use SupportPal\ApiClient\Api\Api;
use SupportPal\ApiClient\Http\Client;
use SupportPal\ApiClient\Model\Model;
Expand Down Expand Up @@ -42,9 +43,14 @@ protected function setUp(): void
*/
protected function makeCommonExpectations(array $responseData, string $model): array
{
$streamProphecy = $this->prophesize(StreamInterface::class);
$streamProphecy->__toString()
->willReturn(json_encode($responseData))
->shouldBeCalled();

$response = $this->prophesize(ResponseInterface::class);
$response->getBody()
->willReturn(json_encode($responseData));
->willReturn($streamProphecy->reveal());

if (is_array(current($responseData['data']))) {
$models = [];
Expand All @@ -68,9 +74,14 @@ protected function makeCommonExpectations(array $responseData, string $model): a
*/
protected function makeSuccessResponse()
{
$streamProphecy = $this->prophesize(StreamInterface::class);
$streamProphecy->__toString()
->willReturn(json_encode(['status' => 'success']))
->shouldBeCalled();

$response = $this->prophesize(ResponseInterface::class);
$response->getBody()
->willReturn(json_encode(['status' => 'success']));
->willReturn($streamProphecy->reveal());

return $response;
}
Expand Down

0 comments on commit bae45f7

Please sign in to comment.