/**
  * Stub a Guzzle call (processed request)
  *
  * @param Guzzle\Http\Message\RequestInterface $request
  * @param Guzzle\Http\Message\Response         $response
  * @param array                                $info    call information
  *
  * @return Guzzle\Http\Message\RequestInterface
  */
 protected function stubCall($request, $response, array $info)
 {
     $request->expects($this->any())->method('getResponse')->will($this->returnValue($response));
     $response->expects($this->any())->method('getInfo')->with($this->logicalOr($this->equalTo('connect_time'), $this->equalTo('total_time')))->will($this->returnCallback(function ($arg) use($info) {
         if (!isset($info[$arg])) {
             throw new Exception(sprintf('%s is not a mocked information', $arg));
         }
         return $info[$arg];
     }));
     return $request;
 }
예제 #2
0
 /**
  * @param Guzzle\Http\Client                   $httpClient
  * @param Guzzle\Http\Message\RequestInterface $request
  * @param Guzzle\Http\Message\Response         $response
  * @param Guzzle\Http\QueryString              $queryString
  */
 function let($httpClient, $request, $response, $queryString)
 {
     $request->getQuery()->willReturn($queryString);
     $request->send()->willReturn($response);
     $this->beConstructedWith($httpClient);
 }
예제 #3
0
 /**
  * @param Git_RemoteServer_GerritServer        $server
  * @param Guzzle\Http\Message\RequestInterface $request
  *
  * @return Guzzle\Http\Message\Response
  */
 private function sendRequest(Git_RemoteServer_GerritServer $server, Guzzle\Http\Message\RequestInterface $request)
 {
     $request->setAuth($server->getLogin(), $server->getHTTPPassword(), 'Digest');
     return $request->send();
 }