fix HttpMessage::toMessageTypeObject()
[m6w6/ext-http] / tests / HttpMessage_008.phpt
diff --git a/tests/HttpMessage_008.phpt b/tests/HttpMessage_008.phpt
new file mode 100644 (file)
index 0000000..66e41dc
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+HttpMessage::toMessageTypeObject()
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkver(5);
+checkcls('HttpRequest');
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+
+$b = HttpRequest::encodeBody(array("a"=>"b",1=>2),null);
+
+$m = new HttpMessage;
+$m->setType(HttpMessage::TYPE_REQUEST);
+$m->setRequestMethod('POST');
+$m->setRequestUrl("http://www.example.com");
+$m->setHttpVersion('1.1');
+$m->addHeaders(
+       array(
+               "Content-Type"  => "application/x-www-form-urlencoded",
+               "Host"                  => "www.example.com",
+               "Content-Length"=> strlen($b),
+       )
+);
+$m->setBody($b);
+$r = $m->toMessageTypeObject();
+echo $m,"\n";
+echo "Done\n";
+?>
+--EXPECTF--
+%aTEST
+POST http://www.example.com HTTP/1.1
+Content-Type: application/x-www-form-urlencoded
+Host: www.example.com
+Content-Length: 7
+
+a=b&1=2
+
+Done