Ejemplo n.º 1
0
 public function testManagesHandles()
 {
     $m = curl_multi_init();
     $b = new BatchContext($m, true);
     $h = curl_init();
     $t = new Transaction(new Client(), new Request('GET', 'http://httbin.org'));
     $b->addTransaction($t, $h);
     $this->assertSame($t, $b->findTransaction($h));
     $b->removeTransaction($t);
     try {
         $this->assertEquals([], $b->findTransaction($h));
         $this->fail('Did not throw');
     } catch (\RuntimeException $e) {
     }
     curl_multi_close($m);
 }
Ejemplo n.º 2
0
 private function processMessages(BatchContext $context)
 {
     $multi = $context->getMultiHandle();
     while ($done = curl_multi_info_read($multi)) {
         $transaction = $context->findTransaction($done['handle']);
         $this->processResponse($transaction, $done, $context);
         // Add the next transaction if there are more in the queue
         if ($next = $context->nextPending()) {
             $this->addHandle($next, $context);
         }
     }
 }