- fix crash with custom content-type when no other options are set
[m6w6/ext-http] / tests / HttpRequest_006.phpt
diff --git a/tests/HttpRequest_006.phpt b/tests/HttpRequest_006.phpt
new file mode 100644 (file)
index 0000000..57eda66
--- /dev/null
@@ -0,0 +1,144 @@
+--TEST--
+HttpRequest XMLRPC
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkext('xmlrpc');
+checkcls('HttpRequest');
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+
+$r = new HttpRequest('http://dev.iworks.at/.print_request.php', HTTP_METH_POST);
+$r->setContentType('text/xml');
+$r->setRawPostData(xmlrpc_encode_request('testMethod', array('foo' => 'bar')));
+var_dump($r->send());
+var_dump($r->send());
+var_dump($r->send());
+
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+object(HttpMessage)#%d (%d) {
+  ["type:protected"]=>
+  int(2)
+  ["httpVersion:protected"]=>
+  float(1.1)
+  ["responseCode:protected"]=>
+  int(200)
+  ["responseStatus:protected"]=>
+  string(2) "OK"
+  ["requestMethod:protected"]=>
+  string(0) ""
+  ["requestUri:protected"]=>
+  string(0) ""
+  ["headers:protected"]=>
+  array(6) {
+    %s
+  }
+  ["body:protected"]=>
+  string(310) "string(294) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>testMethod</methodName>
+<params>
+ <param>
+  <value>
+   <struct>
+    <member>
+     <name>foo</name>
+     <value>
+      <string>bar</string>
+     </value>
+    </member>
+   </struct>
+  </value>
+ </param>
+</params>
+</methodCall>
+"
+
+"
+}
+object(HttpMessage)#%d (%d) {
+  ["type:protected"]=>
+  int(2)
+  ["httpVersion:protected"]=>
+  float(1.1)
+  ["responseCode:protected"]=>
+  int(200)
+  ["responseStatus:protected"]=>
+  string(2) "OK"
+  ["requestMethod:protected"]=>
+  string(0) ""
+  ["requestUri:protected"]=>
+  string(0) ""
+  ["headers:protected"]=>
+  array(6) {
+    %s
+  }
+  ["body:protected"]=>
+  string(310) "string(294) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>testMethod</methodName>
+<params>
+ <param>
+  <value>
+   <struct>
+    <member>
+     <name>foo</name>
+     <value>
+      <string>bar</string>
+     </value>
+    </member>
+   </struct>
+  </value>
+ </param>
+</params>
+</methodCall>
+"
+
+"
+}
+object(HttpMessage)#%d (%d) {
+  ["type:protected"]=>
+  int(2)
+  ["httpVersion:protected"]=>
+  float(1.1)
+  ["responseCode:protected"]=>
+  int(200)
+  ["responseStatus:protected"]=>
+  string(2) "OK"
+  ["requestMethod:protected"]=>
+  string(0) ""
+  ["requestUri:protected"]=>
+  string(0) ""
+  ["headers:protected"]=>
+  array(6) {
+    %s
+  }
+  ["body:protected"]=>
+  string(310) "string(294) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>testMethod</methodName>
+<params>
+ <param>
+  <value>
+   <struct>
+    <member>
+     <name>foo</name>
+     <value>
+      <string>bar</string>
+     </value>
+    </member>
+   </struct>
+  </value>
+ </param>
+</params>
+</methodCall>
+"
+
+"
+}
+Done