Skip to content

Commit

Permalink
Adjust tests to deal with Guzzle 6 and 7
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Sep 21, 2020
1 parent 97f1249 commit 1aa207c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/SaferpayJson/Tests/Request/CommonRequestTest.php
Expand Up @@ -62,9 +62,11 @@ private function executeRequest(): Response

private function getClientMock(): MockObject
{
$mockMethod = $this->getMockMethodBasedOnGuzzleVersion();

$browser = $this->getMockBuilder(Client::class)
->disableOriginalConstructor()
->onlyMethods(['post'])
->$mockMethod(['post'])
->getMock();

$browser->expects($this->once())
Expand Down Expand Up @@ -110,4 +112,11 @@ private function getFakedApiResponse(string $class): string

return $serializer->serialize($response, 'json');
}

private function getMockMethodBasedOnGuzzleVersion()
{
$reflection = new \ReflectionClass(Client::class);

return count($reflection->getTraits()) ? 'onlyMethods' : 'addMethods';
}
}

0 comments on commit 1aa207c

Please sign in to comment.