f6094bb03580879b78e58890c5541795606c2547
[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(150) "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 "
55 array(2) {
56 [0]=>
57 array(2) {
58 ["int"]=>
59 int(1)
60 ["dbl"]=>
61 float(3.1415926535898)
62 }
63 [1]=>
64 array(2) {
65 ["str"]=>
66 string(9) "something"
67 ["nil"]=>
68 NULL
69 }
70 }
71
72 Second Request
73 string(270) "Array
74 (
75 [0] => Array
76 (
77 [int] => 1
78 [dbl] => 3.1415926535898
79 )
80
81 [1] => Array
82 (
83 [str] => something
84 [nil] =>
85 )
86
87 )
88 string(56) "0[int]=1&0[dbl]=3.1415926535898&1[str]=something&1[nil]="
89
90 "
91 array(2) {
92 [0]=>
93 array(2) {
94 ["int"]=>
95 int(1)
96 ["dbl"]=>
97 float(3.1415926535898)
98 }
99 [1]=>
100 array(2) {
101 ["str"]=>
102 string(9) "something"
103 ["nil"]=>
104 NULL
105 }
106 }
107
108 Third Request
109 string(287) "Array
110 (
111 [0] => Array
112 (
113 [int] => 1
114 [dbl] => 3.1415926535898
115 )
116
117 [1] => Array
118 (
119 [str] => something
120 [nil] =>
121 )
122
123 [x] => X
124 )
125 string(60) "0[int]=1&0[dbl]=3.1415926535898&1[str]=something&1[nil]=&x=X"
126
127 "
128 array(2) {
129 [0]=>
130 array(2) {
131 ["int"]=>
132 int(1)
133 ["dbl"]=>
134 float(3.1415926535898)
135 }
136 [1]=>
137 array(2) {
138 ["str"]=>
139 string(9) "something"
140 ["nil"]=>
141 NULL
142 }
143 }
144
145 Fourth Request
146 string(14) "string(0) ""
147
148 "
149 array(2) {
150 [0]=>
151 array(2) {
152 ["int"]=>
153 int(1)
154 ["dbl"]=>
155 float(3.1415926535898)
156 }
157 [1]=>
158 array(2) {
159 ["str"]=>
160 string(9) "something"
161 ["nil"]=>
162 NULL
163 }
164 }
165 Done
166