Exemple #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()));
     }
 }
Exemple #2
0
 protected function useResponse(Request $request, Response $response, $filter = null)
 {
     if ($request->isExpectingResult()) {
         $this->serializer->expects($this->once())->method($response->getType() === MessageTypes::ERROR ? 'serializeError' : 'serializeResult')->with($request->getMethodName(), $this->equalTo($response->getResultBody(), 0, 0), $response->getHeaders()->get('content-type'))->will($this->returnValue($response->getResultBody()));
     } else {
         $this->serializer->expects($this->never())->method('serializeResult');
     }
     if (!$filter) {
         $filter = function () {
         };
     }
     $this->transport->expects($this->once())->method('sendResponse')->with($response)->will($this->returnCallback($filter));
 }