3 class PoolTest
extends PHPUnit_Framework_TestCase
5 /*function testStandard() {
6 foreach (http\Client\Factory::getAvailableDrivers() as $driver) {
7 $f = new http\Client\Factory(compact("driver"));
10 $this->assertFalse($p->dns, "dns");
11 $this->assertFalse($p->cookie, "cookie");
12 $this->assertFalse($p->ssl, "ssl");
18 $this->assertTrue($p->dns, "dns");
19 $this->assertTrue($p->cookie, "cookie");
20 $this->assertTrue($p->ssl, "ssl");
24 function testAttach() {
25 foreach (http\Client\Factory
::getAvailableDrivers() as $driver) {
26 $f = new http\Client\
Factory(compact("driver"));
28 $p = $f->createPool();
29 $c = $f->createClient();
31 $c->setRequest(new http\Client\
Request("GET", "https://twitter.com/"));
36 } catch (http\Exception
$e) {
37 $this->assertEquals("Could not attach request to pool: Invalid easy handle", $e->getMessage());
43 $this->assertEquals(2, count($p));
48 $client = new http\Curl\Client
;
49 $client->setRequest(new http\Client\
Request("GET", "https://twitter.com/"));
50 $pool = new http\Curl\Client\Pool
;
51 $pool->attach($client);
52 $pool->attach($client2 = clone $client);
53 $pool->attach($client3 = clone $client);
55 $this->assertEquals(3, count($pool));
58 $pool->detach($client);
59 $this->assertEquals(2, count($pool));
62 $this->assertEquals(0, count($pool));
65 function testCurlEvents() {
66 $client = new http\Curl\Client
;
67 $pool = new http\Curl\Client\Pool
;
69 $client->setRequest(new http\Client\
Request("GET", "https://twitter.com/"));
71 $pool->attach($client);
72 $pool->attach(clone $client);
73 $pool->attach(clone $client);
75 $pool->enableEvents();