prepare v4.2.5
[m6w6/ext-http] / tests / message002.phpt
1 --TEST--
2 env request message
3 --SKIPIF--
4 <?php include "skipif.inc"; ?>
5 --POST_RAW--
6 Content-Type: test/something
7 b=c
8 --ENV--
9 HTTP_X_TEST=test
10 --COOKIE--
11 foo=bar
12 --INI--
13 always_populate_raw_post_data=-1
14 --FILE--
15 <?php
16 echo "Test\n";
17
18 use http\env\Request as HttpEnvRequest;
19
20 $m = new HttpEnvRequest();
21
22 // travis' env headers have another order, wtf?
23 $h = $m->getHeaders();
24 ksort($h);
25 $m->setHeaders($h);
26
27 var_dump($m);
28
29 echo "Message->toString\n";
30 echo $m,"\n";
31
32 echo "Body->toString\n";
33 var_dump((string)$m->getBody());
34
35 echo "stream\n";
36 var_dump(file_get_contents("php://input"));
37 ?>
38 Done
39 --EXPECTF--
40 Test
41 object(%s)#%d (13) {
42 ["type":protected]=>
43 int(1)
44 ["body":protected]=>
45 object(http\Message\Body)#3 (0) {
46 }
47 ["requestMethod":protected]=>
48 string(4) "POST"
49 ["requestUrl":protected]=>
50 string(0) ""
51 ["responseStatus":protected]=>
52 string(0) ""
53 ["responseCode":protected]=>
54 int(0)
55 ["httpVersion":protected]=>
56 string(3) "1.1"
57 ["headers":protected]=>
58 array(4) {
59 ["Content-Length"]=>
60 string(1) "3"
61 ["Content-Type"]=>
62 string(14) "test/something"
63 ["Cookie"]=>
64 string(7) "foo=bar"
65 ["X-Test"]=>
66 string(4) "test"
67 }
68 ["parentMessage":protected]=>
69 NULL
70 ["query":protected]=>
71 object(http\QueryString)#%d (1) {
72 ["queryArray":"http\QueryString":private]=>
73 array(0) {
74 }
75 }
76 ["form":protected]=>
77 object(http\QueryString)#%d (1) {
78 ["queryArray":"http\QueryString":private]=>
79 array(0) {
80 }
81 }
82 ["cookie":protected]=>
83 object(http\QueryString)#%d (1) {
84 ["queryArray":"http\QueryString":private]=>
85 array(1) {
86 ["foo"]=>
87 string(3) "bar"
88 }
89 }
90 ["files":protected]=>
91 array(0) {
92 }
93 }
94 Message->toString
95 POST / HTTP/1.1%a
96 Content-Length: 3%a
97 Content-Type: test/something%a
98 Cookie: foo=bar%a
99 X-Test: test%a
100 %a
101 b=c
102 Body->toString
103 string(3) "b=c"
104 stream
105 string(3) "b=c"
106 Done