public function testWrapOAuthError()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|RequestException $exception */
     $exception = $this->getMockBuilder(RequestException::class)->disableOriginalConstructor()->getMock();
     $request = $this->getMock(RequestInterface::class);
     $response = $this->getMock(ResponseInterface::class);
     $stream = $this->getMock(StreamInterface::class);
     $exception->expects($this->any())->method('getRequest')->willReturn($request);
     $exception->expects($this->any())->method('getResponse')->willReturn($response);
     $response->expects($this->any())->method('getBody')->willReturn($stream);
     $stream->expects($this->any())->method('__toString')->willReturn(json_encode(['error' => 'ID', 'error_description' => 'MESSAGE']));
     $actual = HttpException::wrap($exception);
     $this->assertCount(1, $actual->getErrors());
     $this->assertInstanceOf(Error::class, $actual->getError());
     $this->assertEquals('ID', $actual->getError()->getId());
     $this->assertEquals('MESSAGE', $actual->getError()->getMessage());
 }
 private function send(RequestInterface $request, array $params = [])
 {
     $this->lastRequest = $request;
     $options = $this->prepareOptions($request->getMethod(), $request->getRequestTarget(), $params);
     try {
         $this->lastResponse = $response = $this->transport->send($request, $options);
     } catch (RequestException $e) {
         throw HttpException::wrap($e);
     }
     if ($this->logger) {
         $this->logWarnings($response);
     }
     return $response;
 }