Skip to content

Commit

Permalink
Fix AbstractProviderTest::testResponseParsingException
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasan committed Nov 3, 2020
1 parent 18131dc commit 6d3d013
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/src/Provider/AbstractProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ public function parseResponseProvider()
/**
* @dataProvider parseResponseProvider
*/
public function testParseResponse($body, $type, $parsed, $statusCode = 200)
public function testParseResponse($body, $type, $parsed, $statusCode = 200, $provider = null)
{
$stream = Mockery::mock(StreamInterface::class, [
'__toString' => $body,
Expand All @@ -633,7 +633,12 @@ public function testParseResponse($body, $type, $parsed, $statusCode = 200)
->andReturn($type);

$method = $this->getMethod(AbstractProvider::class, 'parseResponse');
$result = $method->invoke($this->getMockProvider(), $response);

if (null === $provider) {
$provider = $this->getMockProvider();
}

$result = $method->invoke($provider, $response);

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

public function testResponseParsingException()
{
$this->provider->allowResponseParsingException();
$provider = $this->getMockProvider();
$provider->allowResponseParsingException();
$exception = null;
try {
$this->testParseResponse('{13}', '', null, 401);
$this->testParseResponse('{13}', 'application/json', null, 401, $provider);
} catch (ResponseParsingException $exception) {
}
$this->assertInstanceOf(ResponseParsingException::class, $exception);
$response = $exception->getResponse();
$this->assertSame(401, $response->getStatusCode());
$this->assertSame('{13}', $exception->getResponseBody());
$this->provider->disallowResponseParsingException();
$provider->disallowResponseParsingException();
}

public function getAppendQueryProvider()
Expand Down

0 comments on commit 6d3d013

Please sign in to comment.