Skip to content

Commit 6d3d013

Browse files
author
Hasan
committed
Fix AbstractProviderTest::testResponseParsingException
1 parent 18131dc commit 6d3d013

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/src/Provider/AbstractProviderTest.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ public function parseResponseProvider()
617617
/**
618618
* @dataProvider parseResponseProvider
619619
*/
620-
public function testParseResponse($body, $type, $parsed, $statusCode = 200)
620+
public function testParseResponse($body, $type, $parsed, $statusCode = 200, $provider = null)
621621
{
622622
$stream = Mockery::mock(StreamInterface::class, [
623623
'__toString' => $body,
@@ -633,7 +633,12 @@ public function testParseResponse($body, $type, $parsed, $statusCode = 200)
633633
->andReturn($type);
634634

635635
$method = $this->getMethod(AbstractProvider::class, 'parseResponse');
636-
$result = $method->invoke($this->getMockProvider(), $response);
636+
637+
if (null === $provider) {
638+
$provider = $this->getMockProvider();
639+
}
640+
641+
$result = $method->invoke($provider, $response);
637642

638643
$this->assertEquals($parsed, $result);
639644
}
@@ -652,17 +657,18 @@ public function testParseResponseNonJsonFailure()
652657

653658
public function testResponseParsingException()
654659
{
655-
$this->provider->allowResponseParsingException();
660+
$provider = $this->getMockProvider();
661+
$provider->allowResponseParsingException();
656662
$exception = null;
657663
try {
658-
$this->testParseResponse('{13}', '', null, 401);
664+
$this->testParseResponse('{13}', 'application/json', null, 401, $provider);
659665
} catch (ResponseParsingException $exception) {
660666
}
661667
$this->assertInstanceOf(ResponseParsingException::class, $exception);
662668
$response = $exception->getResponse();
663669
$this->assertSame(401, $response->getStatusCode());
664670
$this->assertSame('{13}', $exception->getResponseBody());
665-
$this->provider->disallowResponseParsingException();
671+
$provider->disallowResponseParsingException();
666672
}
667673

668674
public function getAppendQueryProvider()

0 commit comments

Comments
 (0)