Skip to content

Commit

Permalink
✅ Clean up mocks
Browse files Browse the repository at this point in the history
Latest dependencies complain about the type being returned. This returns
a stream of the mock content and also removes an unneccessary mock.
  • Loading branch information
amcintosh committed Jun 7, 2023
1 parent 5836dfd commit 6eb7400
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/Resource/BaseResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace amcintosh\FreshBooks\Tests\Resource;

use GuzzleHttp\Psr7;
use Http\Discovery\Psr17FactoryDiscovery;
use amcintosh\FreshBooks\Tests\Util\MockHttpClient;

Expand All @@ -15,12 +16,10 @@ public function getMockHttpClient(int $status = 200, array $content = null): Moc
Psr17FactoryDiscovery::findRequestFactory(),
Psr17FactoryDiscovery::findStreamFactory()
);
$mockContent = $this->getMockBuilder(\stdclass::class)->setMethods(['getContents'])->getMock();
$mockContent->method('getContents')->will($this->returnValue(json_encode($content)));

$response = $this->createMock('Psr\Http\Message\ResponseInterface');
$response->method('getStatusCode')->will($this->returnValue($status));
$response->method('getBody')->will($this->returnValue($mockContent));
$response->method('getBody')->will($this->returnValue(Psr7\Utils::streamFor(json_encode($content))));
$mockHttpClient->addResponse($response);
return $mockHttpClient;
}
Expand Down

0 comments on commit 6eb7400

Please sign in to comment.