public function testManagesHandles() { $m = curl_multi_init(); $b = new puzzle_adapter_curl_BatchContext($m, true); $h = curl_init(); $t = new puzzle_adapter_Transaction(new puzzle_Client(), new puzzle_message_Request('GET', 'http://httbin.org')); $b->addTransaction($t, $h); $this->assertTrue($b->isActive()); $this->assertSame($t, $b->findTransaction($h)); $b->removeTransaction($t); $this->assertFalse($b->isActive()); try { $this->assertEquals(array(), $b->findTransaction($h)); $this->fail('Did not throw'); } catch (RuntimeException $e) { } curl_multi_close($m); }
private function processMessages(puzzle_adapter_curl_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); } } }