From 1aa207c19ea63390d23edd0a46e984e5f4023031 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 21 Sep 2020 21:06:40 +0200 Subject: [PATCH] Adjust tests to deal with Guzzle 6 and 7 --- .../SaferpayJson/Tests/Request/CommonRequestTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php index bf8ac61..c9b609c 100644 --- a/tests/SaferpayJson/Tests/Request/CommonRequestTest.php +++ b/tests/SaferpayJson/Tests/Request/CommonRequestTest.php @@ -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()) @@ -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'; + } }