3 class UserClient
extends http\Client\AbstractClient
{
4 function send($request = null) {
9 class DataShareTest
extends PHPUnit_Framework_TestCase
11 function testStandard() {
12 foreach (http\Client\Factory
::getAvailableDrivers() as $driver) {
13 $f = new http\Client\
Factory(compact("driver"));
14 $s = $f->createDataShare();
16 $this->assertFalse($s->dns
, "dns");
17 $this->assertFalse($s->cookie
, "cookie");
18 $this->assertFalse($s->ssl
, "ssl");
24 $this->assertTrue($s->dns
, "dns");
25 $this->assertTrue($s->cookie
, "cookie");
26 $this->assertTrue($s->ssl
, "ssl");
30 function testAttach() {
31 foreach (http\Client\Factory
::getAvailableDrivers() as $driver) {
32 $f = new http\Client\
Factory(compact("driver"));
33 $s = $f->createDataShare();
34 $s->dns
= $s->ssl
= $s->cookie
= true;
35 $c = $f->createClient();
37 $c->setRequest(new http\Client\
Request("GET", "https://twitter.com/"));
42 $this->assertEquals(3, count($s));
47 $client = new http\Curl\Client
;
48 $client->setRequest(new http\Client\
Request("GET", "https://twitter.com/"));
49 $share = new http\Curl\Client\DataShare
;
50 $share->ssl
= $share->dns
= $share->cookie
= true;
51 $share->attach($client);
52 $share->attach($client2 = clone $client);
53 $share->attach($client3 = clone $client);
55 $this->assertEquals(3, count($share));
60 $share->detach($client);
64 function testCurlIncompatible() {
65 $client = new UserClient
;
66 $client->setRequest(new http\Client\
Request("GET", "https://twitter.com"));
68 $share = new http\Curl\Client\DataShare
;
69 $this->setExpectedException("PHPUnit_Framework_Error_Warning");
70 $share->attach($client);
71 $this->setExpectedException("PHPUnit_Framework_Error_Warning");
72 $share->detach($client);