diff --git a/src/Service/Decoder/JsonResponseDecoder.php b/src/Service/Decoder/JsonResponseDecoder.php index 15e6446..605d14f 100644 --- a/src/Service/Decoder/JsonResponseDecoder.php +++ b/src/Service/Decoder/JsonResponseDecoder.php @@ -52,7 +52,7 @@ public function getDecodedResponse(Request $request) } if (json_last_error() !== JSON_ERROR_NONE) { - $decodedResponse = $response->getBody()->getContents(); + return $response->getBody()->getContents(); } if ($this->cacheEndpoint) { diff --git a/tests/Service/Decoder/JsonResponseDecoderTest.php b/tests/Service/Decoder/JsonResponseDecoderTest.php index 09ff6b5..51fcd15 100644 --- a/tests/Service/Decoder/JsonResponseDecoderTest.php +++ b/tests/Service/Decoder/JsonResponseDecoderTest.php @@ -145,7 +145,6 @@ public function testGetDecodedResponseThrowsNetworkExceptionWhenClientFailsAndNo } /** - * @todo this seems like a bug, we should not store in the cache invalid json? should we throw an error? * @throws \Http\Client\Exception * @throws \Psr\SimpleCache\InvalidArgumentException */ @@ -159,7 +158,7 @@ public function testGetDecodedResponseReturnsBodyWhenJsonDecodingFails() $response->getBody()->willReturn($this->getResponseBodyStub('{invalid_json')); $this->client->sendRequest($request)->willReturn($response->reveal()); - $this->simpleCache->set('4429b090fd82239e188859ae626162e5e790b4db', '{invalid_json')->shouldBeCalledOnce(); + $this->simpleCache->set('4429b090fd82239e188859ae626162e5e790b4db', '{invalid_json')->shouldNotBeCalled(); $this->assertSame( '{invalid_json',