X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=phpunit%2FRequestTest.php;h=a327f6dff2440eb49a26a118dadeb6a9ae649e5d;hb=575f4ce7a82c2c2bf4fb597f6a3a3de077403910;hp=56053ee148d5a487db4ee7d091a5a1f20874ac88;hpb=efdbb46bf78df0d34936c536bd78b05abadd3a0d;p=m6w6%2Fext-http diff --git a/phpunit/RequestTest.php b/phpunit/RequestTest.php index 56053ee..a327f6d 100644 --- a/phpunit/RequestTest.php +++ b/phpunit/RequestTest.php @@ -35,6 +35,18 @@ class RequestTest extends PHPUnit_Framework_TestCase "timeout" => 300, ) ); + $this->r->setOptions( + array( + "timeout" => 600 + ) + ); + $this->assertEquals( + array( + "connecttimeout" => 30, + "timeout" => 600, + ), + $this->r->getOptions() + ); } function testClone() { @@ -43,10 +55,10 @@ class RequestTest extends PHPUnit_Framework_TestCase } function testObserver() { - $this->r->attach(new ProgressObserver1); - $this->r->attach(new ProgressObserver2); + $this->r->attach($o1 = new ProgressObserver1); + $this->r->attach($o2 = new ProgressObserver2); $this->r->attach( - new CallbackObserver( + $o3 = new CallbackObserver( function ($r) { $p = (array) $r->getProgress(); $this->assertArrayHasKey("started", $p); @@ -62,6 +74,12 @@ class RequestTest extends PHPUnit_Framework_TestCase $this->r->setRequest(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/"))->send(null); $this->assertRegexp("/(\.-)+/", $this->r->pi); $this->assertCount(3, $this->r->getObservers()); + $this->r->detach($o1); + $this->assertCount(2, $this->r->getObservers()); + $this->r->detach($o2); + $this->assertCount(1, $this->r->getObservers()); + $this->r->detach($o3); + $this->assertCount(0, $this->r->getObservers()); } function testCookies() { @@ -92,6 +110,23 @@ class RequestTest extends PHPUnit_Framework_TestCase $this->r->send(null); $this->assertNotEquals($c, array_map($f, $this->r->getResponseMessage()->getCookies())); } + + function testSsl() { + $this->r->setRequest(new http\Client\Request("GET", "https://twitter.com/")); + $this->r->setSslOptions(array("verify_peer" => true)); + $this->r->addSslOptions(array("verify_host" => 2)); + $this->assertEquals( + array( + "verify_peer" => true, + "verify_host" => 2, + ), + $this->r->getSslOptions() + ); + $this->r->send(); + $ti = $this->r->getTransferInfo(); + $this->assertArrayHasKey("ssl_engines", $ti); + $this->assertGreaterThan(0, count($ti["ssl_engines"])); + } function testHistory() { $body = new http\Message\Body;