Example #1
0
 protected function useResponse(Request $request, Response $response, $unserializeResult = true)
 {
     $this->transport->expects($this->once())->method('receiveResponse')->will($this->returnValue($response));
     if ($unserializeResult && ($request->isExpectingResult() || $response->getType() === MessageTypes::ERROR)) {
         $contentType = $response->getHeaders()->get('content-type');
         $this->serializer->expects($this->once())->method($response->getType() === MessageTypes::ERROR ? 'unserializeError' : 'unserializeResult')->with($request->getMethodName(), $response->getResultBody(), $contentType)->will($this->returnValue($response->getResultBody()));
     }
 }
Example #2
0
 private function handleError(Response $response, Request $request)
 {
     $responseData = $this->serializer->unserializeError($request->getMethodName(), $response->getResultBody(), $response->getHeaders()->get('Content-Type'));
     if ($responseData instanceof \Exception) {
         $this->replaceExceptionTrace($responseData);
         throw $responseData;
     }
     if ($request->getType() === MessageTypes::PING) {
         $msg = 'Error caught during ping';
     } else {
         $msg = 'Error caught during execution of method "' . $request->getMethodName() . '"';
     }
     throw new ErrorResponseException($msg, $responseData);
 }