4c253e095ab8c5ede1c181a0c96c6c7887b01270
[m6w6/ext-http] / tests / HttpRequest_004.phpt
1 --TEST--
2 HttpRequest multiple posts
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkcls('HttpRequest');
7 ?>
8 --FILE--
9 <?php
10 echo "-TEST\n";
11
12 $fields = array(
13 array('int' => 1, 'dbl' => M_PI),
14 array('str' => 'something', 'nil' => null)
15 );
16
17 echo "\nFirst Request\n";
18 $r = new HttpRequest('http://dev.iworks.at/.print_request.php', HttpRequest::METH_POST);
19 $r->setPostFields($fields[0]);
20 $r->addPostFields($fields[1]);
21 var_dump($r->send()->getBody());
22 var_dump($fields);
23
24 echo "\nSecond Request\n";
25 $r->setPostFields($fields);
26 var_dump($r->send()->getBody());
27 var_dump($fields);
28
29 echo "\nThird Request\n";
30 $r->addPostFields(array('x' => 'X'));
31 var_dump($r->send()->getBody());
32 var_dump($fields);
33
34 echo "\nFourth Request\n";
35 $r->setPostFields(array());
36 var_dump($r->send()->getBody());
37 var_dump($fields);
38
39 echo "Done\n";
40 ?>
41 --EXPECTF--
42 %sTEST
43
44 First Request
45 string(149) "Array
46 (
47 [int] => 1
48 [dbl] => 3.1415926535898
49 [str] => something
50 [nil] =>
51 )
52 string(44) "int=1&dbl=3.1415926535898&str=something&nil="
53 "
54 array(2) {
55 [0]=>
56 array(2) {
57 ["int"]=>
58 int(1)
59 ["dbl"]=>
60 float(3.1415926535898)
61 }
62 [1]=>
63 array(2) {
64 ["str"]=>
65 string(9) "something"
66 ["nil"]=>
67 NULL
68 }
69 }
70
71 Second Request
72 string(285) "Array
73 (
74 [0] => Array
75 (
76 [int] => 1
77 [dbl] => 3.1415926535898
78 )
79
80 [1] => Array
81 (
82 [str] => something
83 [nil] =>
84 )
85
86 )
87 string(72) "0%5Bint%5D=1&0%5Bdbl%5D=3.1415926535898&1%5Bstr%5D=something&1%5Bnil%5D="
88 "
89 array(2) {
90 [0]=>
91 array(2) {
92 ["int"]=>
93 int(1)
94 ["dbl"]=>
95 float(3.1415926535898)
96 }
97 [1]=>
98 array(2) {
99 ["str"]=>
100 string(9) "something"
101 ["nil"]=>
102 NULL
103 }
104 }
105
106 Third Request
107 string(302) "Array
108 (
109 [0] => Array
110 (
111 [int] => 1
112 [dbl] => 3.1415926535898
113 )
114
115 [1] => Array
116 (
117 [str] => something
118 [nil] =>
119 )
120
121 [x] => X
122 )
123 string(76) "0%5Bint%5D=1&0%5Bdbl%5D=3.1415926535898&1%5Bstr%5D=something&1%5Bnil%5D=&x=X"
124 "
125 array(2) {
126 [0]=>
127 array(2) {
128 ["int"]=>
129 int(1)
130 ["dbl"]=>
131 float(3.1415926535898)
132 }
133 [1]=>
134 array(2) {
135 ["str"]=>
136 string(9) "something"
137 ["nil"]=>
138 NULL
139 }
140 }
141
142 Fourth Request
143 string(13) "string(0) ""
144 "
145 array(2) {
146 [0]=>
147 array(2) {
148 ["int"]=>
149 int(1)
150 ["dbl"]=>
151 float(3.1415926535898)
152 }
153 [1]=>
154 array(2) {
155 ["str"]=>
156 string(9) "something"
157 ["nil"]=>
158 NULL
159 }
160 }
161 Done
162