From: Michael Wallner Date: Tue, 16 Jul 2013 16:53:35 +0000 (+0000) Subject: converted phpunit ClientRequestTest to PHPTs X-Git-Tag: RELEASE_2_1_0_RC3~10^2^2~25 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a58a67d529ad662546ec8144226042c7e150c163;p=m6w6%2Fext-http converted phpunit ClientRequestTest to PHPTs --- diff --git a/package.xml b/package.xml index ac62a6a..158a29c 100644 --- a/package.xml +++ b/package.xml @@ -129,45 +129,75 @@ Extended HTTP support. Again. Keep in mind that it's got the major version 2, be - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/phpunit/ClientRequestTest.php b/phpunit/ClientRequestTest.php deleted file mode 100644 index f14f49e..0000000 --- a/phpunit/ClientRequestTest.php +++ /dev/null @@ -1,43 +0,0 @@ -assertEquals($b, $r->getBody()); - $this->assertEquals($h, $r->getHeaders()); - $this->assertEquals($u, $r->getRequestUrl()); - $this->assertEquals($m, $r->getRequestMethod()); - } - - function testContentType() { - $r = new Request("POST", "http://localhost/"); - $this->assertEquals($r, $r->setContentType($ct = "text/plain; charset=utf-8")); - $this->assertEquals($ct, $r->getContentType()); - } - - function testQuery() { - $r = new Request("GET", "http://localhost/"); - $this->assertEquals(null, $r->getQuery()); - $this->assertEquals($r, $r->setQuery($q = "foo=bar")); - $this->assertEquals($q, $r->getQuery()); - $this->assertEquals($r, $r->addQuery("a[]=1&a[]=2")); - $this->assertEquals("foo=bar&a%5B0%5D=1&a%5B1%5D=2", $r->getQuery()); - $this->assertEquals(null, $r->setQuery(null)->getQuery()); - } - - function testOptions() { - $r = new Request("GET", "http://localhost"); - $this->assertEquals($r, $r->setOptions($o = array("redirect"=>5, "timeout"=>5))); - $this->assertEquals($o, $r->getOptions()); - $this->assertEquals($r, $r->setSslOptions($o = array("verify_peer"=>false))); - $this->assertEquals($o, $r->getSslOptions()); - } -} - diff --git a/tests/clientrequest001.phpt b/tests/clientrequest001.phpt new file mode 100644 index 0000000..48c863e --- /dev/null +++ b/tests/clientrequest001.phpt @@ -0,0 +1,32 @@ +--TEST-- +client request +--SKIPIF-- + +--FILE-- +getBody()); +var_dump($h === $r->getHeaders()); +var_dump($u === $r->getRequestUrl()); +var_dump($m === $r->getRequestMethod()); + +?> +Done +--EXPECT-- +Test +bool(true) +bool(true) +bool(true) +bool(true) +Done diff --git a/tests/clientrequest002.phpt b/tests/clientrequest002.phpt new file mode 100644 index 0000000..dd82337 --- /dev/null +++ b/tests/clientrequest002.phpt @@ -0,0 +1,22 @@ +--TEST-- +client request content type +--SKIPIF-- + +--FILE-- +setContentType($ct = "text/plain; charset=utf-8")); +var_dump($ct === $r->getContentType()); + +?> +Done +--EXPECT-- +Test +bool(true) +bool(true) +Done diff --git a/tests/clientrequest003.phpt b/tests/clientrequest003.phpt new file mode 100644 index 0000000..5d11e09 --- /dev/null +++ b/tests/clientrequest003.phpt @@ -0,0 +1,30 @@ +--TEST-- +client request query +--SKIPIF-- + +--FILE-- +getQuery()); +var_dump($r === $r->setQuery($q = "foo=bar")); +var_dump($q === $r->getQuery()); +var_dump($r === $r->addQuery("a[]=1&a[]=2")); +var_dump("foo=bar&a%5B0%5D=1&a%5B1%5D=2" === $r->getQuery()); +var_dump(null === $r->setQuery(null)->getQuery()); + +?> +Done +--EXPECT-- +Test +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Done diff --git a/tests/clientrequest004.phpt b/tests/clientrequest004.phpt new file mode 100644 index 0000000..abff8d9 --- /dev/null +++ b/tests/clientrequest004.phpt @@ -0,0 +1,26 @@ +--TEST-- +client request options +--SKIPIF-- + +--FILE-- +setOptions($o = array("redirect"=>5, "timeout"=>5))); +var_dump($o === $r->getOptions()); +var_dump($r === $r->setSslOptions($o = array("verify_peer"=>false))); +var_dump($o === $r->getSslOptions()); + +?> +Done +--EXPECT-- +Test +bool(true) +bool(true) +bool(true) +bool(true) +Done