public function testAll()
 {
     $c = $this->getMock('PHPCurl\\CurlWrapper\\Curl', array('getHandle'));
     $c->expects($this->any())->method('getHandle')->will($this->returnValue('bar'));
     $cm = new CurlMulti();
     $this->assertEquals('foo', $cm->getHandle());
     $this->assertEquals('setopt_foo_opt_val', $cm->setOpt('opt', 'val'));
     $this->assertEquals('add_handle_foo_bar', $cm->add($c));
     $this->assertEquals('remove_handle_foo_bar', $cm->remove($c));
     $this->assertEquals('getcontent_bar', $cm->getContent($c));
     $this->assertEquals('select_foo_1', $cm->select());
     $this->assertEquals('select_foo_2.3', $cm->select(2.3));
     $this->assertEquals('info_read_foo', $cm->infoRead($msgs));
     $this->assertEquals(42, $msgs);
     $this->assertEquals('exec_foo', $cm->exec($running));
     $this->assertEquals(24, $running);
     $this->assertEquals('strerror_boo', CurlMulti::strerror('boo'));
     unset($cm);
     $this->assertEquals('close_foo', array_pop(self::$log));
 }
Exemple #2
0
 /**
  * Retry all failed requests of the given array of Curl instances.
  *
  * @param array $curlInstances An array of Curl instances of which failed ones should be retried
  *
  * @return int The number of failed requests which were retried.
  */
 public function retryFailed($curlInstances)
 {
     $failed = 0;
     $curlMultiInstance = new CurlMulti();
     /**
      * @var $curlInstance Curl
      */
     foreach ($curlInstances as $curlInstance) {
         if ($curlInstance->isSuccessful()) {
             continue;
         }
         $curlInstance->setRetryCount($curlInstance->getRetryCount() + 1);
         $curlMultiInstance->addInstance($curlInstance);
         $failed++;
     }
     $curlMultiInstance->exec();
     return $failed;
 }