Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function applyResponse(HttpRequestInterface $request, HttpResponseInterface $response, array $options)
 {
     if ($response instanceof ResponseInterface && isset($options['rpc_error']) && true === $options['rpc_error'] && null !== $response->getRpcErrorCode()) {
         throw RequestException::create($request, $response);
     }
     return $response;
 }
Пример #2
0
 /**
  * @dataProvider dataCreateServerException
  */
 public function testCreateServerException($code)
 {
     $this->request->shouldReceive('getRequestTarget')->once()->withNoArgs()->andReturn('http://foo');
     $this->request->shouldReceive('getRpcMethod')->once()->withNoArgs()->andReturn('foo');
     $this->response->shouldReceive('getRpcErrorCode')->once()->withNoArgs()->andReturn($code);
     $this->response->shouldReceive('getRpcErrorMessage')->once()->withNoArgs()->andReturn('bar');
     $this->response->shouldReceive('getStatusCode')->once()->withNoArgs()->andReturn(200);
     $exception = RequestException::create($this->request, $this->response);
     $this->assertInstanceOf('Graze\\GuzzleHttp\\JsonRpc\\Exception\\ServerException', $exception);
 }