branch off v1 as R_1_7
[m6w6/ext-http] / tests / HttpMessage_003.phpt
1 --TEST--
2 HttpMessage implements Serializable, Countable
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkmin("5.2.5");
7 ?>
8 --FILE--
9 <?php
10 echo "-TEST\n";
11
12 $m = new HttpMessage(
13 "HTTP/1.1 301\r\n".
14 "Location: /anywhere\r\n".
15 "HTTP/1.1 302\r\n".
16 "Location: /somewhere\r\n".
17 "HTTP/1.1 200\r\n".
18 "Transfer-Encoding: chunked\r\n".
19 "\r\n".
20 "01\r\n".
21 "X\r\n".
22 "00"
23 );
24
25 var_dump($m->count());
26 var_dump($m->serialize());
27 $m->unserialize("HTTP/1.1 200 Ok\r\nServer: Funky/1.0");
28 var_dump($m);
29 var_dump($m->count());
30
31 echo "Done\n";
32 ?>
33 --EXPECTF--
34 %aTEST
35 int(3)
36 string(148) "HTTP/1.1 301
37 Location: /anywhere
38 HTTP/1.1 302
39 Location: /somewhere
40 HTTP/1.1 200
41 X-Original-Transfer-Encoding: chunked
42 Content-Length: 1
43
44 X
45 "
46 object(HttpMessage)#%d (%d) {
47 ["type%s]=>
48 int(2)
49 ["body%s]=>
50 string(0) ""
51 ["requestMethod%s]=>
52 string(0) ""
53 ["requestUrl%s]=>
54 string(0) ""
55 ["responseStatus%s]=>
56 string(2) "Ok"
57 ["responseCode%s]=>
58 int(200)
59 ["httpVersion%s]=>
60 float(1.1)
61 ["headers%s]=>
62 array(1) {
63 ["Server"]=>
64 string(9) "Funky/1.0"
65 }
66 ["parentMessage%s]=>
67 NULL
68 }
69 int(1)
70 Done