Exemple #1
0
 /**
  * Lance l'éxécution de l'aspiration
  *
  * @return void
  * @throws
  */
 public function run()
 {
     if (empty($this->log)) {
         throw new Exception('Un logger est nécessaire');
     }
     $this->curl->setLogger($this->log);
     $this->execPlugin('init');
     do {
         $this->curContent = null;
         $this->curCmd = array_pop($this->plan);
         try {
             $this->execPlugin('before', $this->curCmd);
             $this->exec('CallPre', $this->curCmd);
         } catch (Abort $exc) {
             continue;
         }
         // Paramétrage curl
         $this->curl->setOpts($this->curCmd->getCurlOpts());
         // éxecution curl
         $this->curContent = $this->curl->exec($this->curCmd->getUrl());
         $this->exec('CallBack', $this->curCmd);
         $this->execPlugin('after', $this->curCmd);
         $this->exec('CallAfterPlug', $this->curCmd);
         $this->sleep($this->curCmd);
     } while (!empty($this->plan));
 }
Exemple #2
0
 /**
  * Paramétrage de Curl
  *
  * @throws Exception
  */
 public function testCurlConfig()
 {
     $this->given($command = new TestClass('toto'))->assert('Définition d\'une option curl')->array($command->getCurlOpts())->notHasKey(CURLOPT_VERBOSE)->object($command->setCurlOpt(CURLOPT_VERBOSE, true))->isIdenticalTo($command)->array($command->getCurlOpts())->boolean[CURLOPT_VERBOSE]->isTrue()->boolean($command->getCurlOpt(CURLOPT_VERBOSE))->isTrue()->assert('Réécriture d\'une option curl')->object($command->setCurlOpt(CURLOPT_VERBOSE, false))->isIdenticalTo($command)->array($command->getCurlOpts())->boolean[CURLOPT_VERBOSE]->isFalse()->boolean($command->getCurlOpt(CURLOPT_VERBOSE))->isFalse()->assert('Demande d\'information non présente')->exception(function () use($command) {
         $command->getCurlOpt(CURLOPT_BINARYTRANSFER);
     })->hasMessage('Aucun attribut curl du nom de __' . CURLOPT_BINARYTRANSFER . '__');
 }