Пример #1
0
 /**
  * Executes a Psr\Http\Message\RequestInterface and (if applicable) automatically retries
  * when errors occur.
  *
  * @param Google_Client $client
  * @param Psr\Http\Message\RequestInterface $req
  * @return array decoded result
  * @throws Google_Service_Exception on server side error (ie: not authenticated,
  *  invalid or malformed post body, invalid url)
  */
 public static function execute(ClientInterface $client, RequestInterface $request, $expectedClass = null, $config = array(), $retryMap = null)
 {
     $runner = new Google_Task_Runner($config, sprintf('%s %s', $request->getMethod(), (string) $request->getUri()), array(get_class(), 'doExecute'), array($client, $request, $expectedClass));
     if (!is_null($retryMap)) {
         $runner->setRetryMap($retryMap);
     }
     return $runner->run();
 }
Пример #2
0
 /**
  * Executes a Google_Http_Request and (if applicable) automatically retries
  * when errors occur.
  *
  * @param Google_Client $client
  * @param Google_Http_Request $req
  * @return array decoded result
  * @throws Google_Service_Exception on server side error (ie: not authenticated,
  *  invalid or malformed post body, invalid url)
  */
 public static function execute(Google_Client $client, Google_Http_Request $req)
 {
     $runner = new Google_Task_Runner($client, sprintf('%s %s', $req->getRequestMethod(), $req->getUrl()), array(get_class(), 'doExecute'), array($client, $req));
     return $runner->run();
 }
Пример #3
0
 /**
  * Runs the defined task.
  *
  * @return mixed
  */
 private function runTask()
 {
     $task = new Google_Task_Runner($this->client, '', array($this, 'runNextTask'));
     $exception = $this->getMockBuilder('Google_IO_Exception')->disableOriginalConstructor()->setMethods(array('allowedRetries'))->getMock();
     $exceptionCount = 0;
     $exceptionCalls = array();
     for ($i = 0; $i < $this->mockedCallsCount; $i++) {
         if (is_int($this->mockedCalls[$i])) {
             $exceptionCalls[$exceptionCount++] = $this->mockedCalls[$i];
             $this->mockedCalls[$i] = $exception;
         }
     }
     $exception->expects($this->exactly($exceptionCount))->method('allowedRetries')->will(new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($exceptionCalls));
     return $task->run();
 }
 /**
  * Runs the defined task.
  *
  * @return mixed
  */
 private function runTask()
 {
     $task = new Google_Task_Runner($this->retryConfig, '', array($this, 'runNextTask'));
     if (null !== $this->retryMap) {
         $task->setRetryMap($this->retryMap);
     }
     $exception = $this->getMockBuilder('Google_Service_Exception')->setMethods(array('setTraceOptions'))->disableOriginalConstructor()->getMock();
     $exceptionCount = 0;
     $exceptionCalls = array();
     for ($i = 0; $i < $this->mockedCallsCount; $i++) {
         if (is_int($this->mockedCalls[$i])) {
             $exceptionCalls[$exceptionCount++] = $this->mockedCalls[$i];
             $this->mockedCalls[$i] = $exception;
         }
     }
     $task->setRetryMap($exceptionCalls);
     return $task->run();
 }