- class HttpRequestPool implements Countable
[m6w6/ext-http] / tests / HttpMessage_003.phpt
diff --git a/tests/HttpMessage_003.phpt b/tests/HttpMessage_003.phpt
new file mode 100644 (file)
index 0000000..79d0dc6
--- /dev/null
@@ -0,0 +1,67 @@
+--TEST--
+HttpMessage implmenets Serializable, Countable
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkmin(5);
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+
+$m = new HttpMessage(
+       "HTTP/1.1 301\r\n".
+       "Location: /anywhere\r\n".
+       "HTTP/1.1 302\r\n".
+       "Location: /somewhere\r\n".
+       "HTTP/1.1 200\r\n".
+       "Transfer-Encoding: chunked\r\n".
+       "\r\n".
+       "01\r\n".
+       "X\r\n".
+       "00"
+);
+
+var_dump($m->count());
+var_dump($m->serialize());
+$m->unserialize("HTTP/1.1 200 Ok\r\nServer: Funky/1.0");
+var_dump($m);
+var_dump($m->count());
+
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+int(3)
+string(109) "HTTP/1.1 301
+Location: /anywhere
+HTTP/1.1 302
+Location: /somewhere
+HTTP/1.1 200
+Content-Length: 1
+
+X
+"
+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(1) {
+    ["Server"]=>
+    string(9) "Funky/1.0"
+  }
+  ["body:protected"]=>
+  string(0) ""
+}
+int(1)
+Done