converted phpunit ClientRequestTest to PHPTs
authorMichael Wallner <mike@php.net>
Tue, 16 Jul 2013 16:53:35 +0000 (16:53 +0000)
committerMichael Wallner <mike@php.net>
Tue, 16 Jul 2013 16:53:35 +0000 (16:53 +0000)
package.xml
phpunit/ClientRequestTest.php [deleted file]
tests/clientrequest001.phpt [new file with mode: 0644]
tests/clientrequest002.phpt [new file with mode: 0644]
tests/clientrequest003.phpt [new file with mode: 0644]
tests/clientrequest004.phpt [new file with mode: 0644]

index ac62a6aa2cadf6bd7eb50c1b279427cc8938c498..158a29c51677b8b9c38b1d15e0de215cd9797162 100644 (file)
@@ -129,45 +129,75 @@ Extended HTTP support. Again. Keep in mind that it's got the major version 2, be
      <file role="test" name="message_rr_helloworld_chunked.txt"/>
      <file role="test" name="urls.txt"/>
     </dir>
-    <file role="test" name="bug61444.phpt"/>
-    <file role="test" name="envrequestbody001.phpt"/>
-    <file role="test" name="envrequestbody002.phpt"/>
-    <file role="test" name="envrequestbody003.phpt"/>
-    <file role="test" name="envrequestfiles001.phpt"/>
-    <file role="test" name="envrequestfiles002.phpt"/>
-    <file role="test" name="envrequestform.phpt"/>
-    <file role="test" name="envrequestheader001.phpt"/>
-    <file role="test" name="envrequestquery.phpt"/>
-    <file role="test" name="envresponsecodes.phpt"/>
-    <file role="test" name="envresponseheader001.phpt"/>
-    <file role="test" name="envresponseranges001.phpt"/>
-    <file role="test" name="etag001.phpt"/>
-    <file role="test" name="filterchunked.phpt"/>
-    <file role="test" name="filterzlib.phpt"/>
-    <file role="test" name="info.phpt"/>
-    <file role="test" name="info_001.phpt"/>
-    <file role="test" name="message001.phpt"/>
-    <file role="test" name="message002.phpt"/>
-    <file role="test" name="message003.phpt"/>
-    <file role="test" name="message004.phpt"/>
-    <file role="test" name="message005.phpt"/>
-    <file role="test" name="message006.phpt"/>
-    <file role="test" name="negotiate001.phpt"/>
-    <file role="test" name="params001.phpt"/>
-    <file role="test" name="params002.phpt"/>
-    <file role="test" name="phpunit.phpt"/>
-    <file role="test" name="propertyproxy001.phpt"/>
-    <file role="test" name="querystring_001.phpt"/>
-    <file role="test" name="response001.phpt"/>
-    <file role="test" name="response002.phpt"/>
-    <file role="test" name="response003.phpt"/>
-    <file role="test" name="response004.phpt"/>
-    <file role="test" name="response005.phpt"/>
-    <file role="test" name="serialize001.phpt"/>
-    <file role="test" name="url001.phpt"/>
+     <file role="test" name="bug61444.phpt"/>
+     <file role="test" name="client001.phpt"/>
+     <file role="test" name="client002.phpt"/>
+     <file role="test" name="client003.phpt"/>
+     <file role="test" name="client004.phpt"/>
+     <file role="test" name="client005.phpt"/>
+     <file role="test" name="client006.phpt"/>
+     <file role="test" name="client007.phpt"/>
+     <file role="test" name="client008.phpt"/>
+     <file role="test" name="client009.phpt"/>
+     <file role="test" name="client010.phpt"/>
+     <file role="test" name="clientrequest001.phpt"/>
+     <file role="test" name="clientrequest002.phpt"/>
+     <file role="test" name="clientrequest003.phpt"/>
+     <file role="test" name="clientrequest004.phpt"/>
+     <file role="test" name="clientresponse001.phpt"/>
+     <file role="test" name="clientresponse002.phpt"/>
+     <file role="test" name="clientresponse003.phpt"/>
+     <file role="test" name="envrequestbody001.phpt"/>
+     <file role="test" name="envrequestbody002.phpt"/>
+     <file role="test" name="envrequestbody003.phpt"/>
+     <file role="test" name="envrequestfiles001.phpt"/>
+     <file role="test" name="envrequestfiles002.phpt"/>
+     <file role="test" name="envrequestform.phpt"/>
+     <file role="test" name="envrequestheader001.phpt"/>
+     <file role="test" name="envrequestjson001.phpt"/>
+     <file role="test" name="envrequestjson002.phpt"/>
+     <file role="test" name="envrequestquery.phpt"/>
+     <file role="test" name="envresponsebody001.phpt"/>
+     <file role="test" name="envresponsebody002.phpt"/>
+     <file role="test" name="envresponsecodes.phpt"/>
+     <file role="test" name="envresponseheader001.phpt"/>
+     <file role="test" name="envresponseranges001.phpt"/>
+     <file role="test" name="etag001.phpt"/>
+     <file role="test" name="filterchunked.phpt"/>
+     <file role="test" name="filterzlib.phpt"/>
+     <file role="test" name="info_001.phpt"/>
+     <file role="test" name="info.phpt"/>
+     <file role="test" name="message001.phpt"/>
+     <file role="test" name="message002.phpt"/>
+     <file role="test" name="message003.phpt"/>
+     <file role="test" name="message004.phpt"/>
+     <file role="test" name="message005.phpt"/>
+     <file role="test" name="message006.phpt"/>
+     <file role="test" name="negotiate001.phpt"/>
+     <file role="test" name="params001.phpt"/>
+     <file role="test" name="params002.phpt"/>
+     <file role="test" name="phpunit.phpt"/>
+     <file role="test" name="propertyproxy001.phpt"/>
+     <file role="test" name="querystring_001.phpt"/>
+     <file role="test" name="response001.phpt"/>
+     <file role="test" name="response002.phpt"/>
+     <file role="test" name="response003.phpt"/>
+     <file role="test" name="response004.phpt"/>
+     <file role="test" name="response005.phpt"/>
+     <file role="test" name="response006.phpt"/>
+     <file role="test" name="response007.phpt"/>
+     <file role="test" name="response008.phpt"/>
+     <file role="test" name="response009.phpt"/>
+     <file role="test" name="response010.phpt"/>
+     <file role="test" name="response011.phpt"/>
+     <file role="test" name="response012.phpt"/>
+     <file role="test" name="response013.phpt"/>
+     <file role="test" name="response014.phpt"/>
+     <file role="test" name="serialize001.phpt"/>
+     <file role="test" name="url001.phpt"/>
+     <file role="test" name="version001.phpt"/>
    </dir>
    <dir name="phpunit">
-    <file role="test" name="ClientRequestTest.php"/>
     <file role="test" name="ClientTest.php"/>
     <file role="test" name="CookieTest.php"/>
     <file role="test" name="EncodingTest.php"/>
diff --git a/phpunit/ClientRequestTest.php b/phpunit/ClientRequestTest.php
deleted file mode 100644 (file)
index f14f49e..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-use http\Client\Request;
-use http\Message\Body;
-
-class ClientRequestTest extends PHPUnit_Framework_TestCase
-{
-    function testStandard() {
-        $r = new Request($m = "POST", $u = "http://localhost/foo", $h = array("header", "value"),
-            $b = new Body(fopen(__FILE__, "r+b"))
-        );
-
-        $this->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 (file)
index 0000000..48c863e
--- /dev/null
@@ -0,0 +1,32 @@
+--TEST--
+client request
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+echo "Test\n";
+
+$r = new http\Client\Request(
+       $m = "POST", 
+       $u = "http://localhost/foo", 
+       $h = array("header", "value"),
+    $b = new http\Message\Body(fopen(__FILE__, "r+b"))
+);
+
+var_dump($b === $r->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 (file)
index 0000000..dd82337
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+client request content type
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+echo "Test\n";
+
+$r = new http\Client\Request("POST", "http://localhost/");
+var_dump($r === $r->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 (file)
index 0000000..5d11e09
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+client request query
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+echo "Test\n";
+
+$r = new http\Client\Request("GET", "http://localhost/");
+var_dump(null === $r->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 (file)
index 0000000..abff8d9
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+client request options
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+echo "Test\n";
+
+$r = new http\Client\Request("GET", "http://localhost");
+var_dump($r === $r->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