simplify
[m6w6/ext-http] / tests / urlparser009.phpt
1 --TEST--
2 url parser userinfo
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 ?>
7 --FILE--
8 <?php
9 echo "Test\n";
10
11 $urls = array(
12 "s://:@",
13 "s://u@",
14 "s://u:@",
15 "s://u:p@",
16 "s://user:pass@",
17 "s://user:pass@host",
18 "s://u@h",
19 "s://user@h",
20 "s://u@host",
21 "s://user:p@h",
22 "s://user:pass@h",
23 "s://user:pass@host",
24 );
25
26 foreach ($urls as $url) {
27 try {
28 printf("\n%s\n", $url);
29 var_dump(http\Url::parse($url));
30 } catch (Exception $e) {
31 echo $e->getMessage(),"\n";
32 }
33 }
34 ?>
35 DONE
36 --EXPECTF--
37 Test
38
39 s://:@
40 object(http\Url)#1 (8) {
41 ["scheme"]=>
42 string(1) "s"
43 ["user"]=>
44 string(0) ""
45 ["pass"]=>
46 string(0) ""
47 ["host"]=>
48 NULL
49 ["port"]=>
50 NULL
51 ["path"]=>
52 NULL
53 ["query"]=>
54 NULL
55 ["fragment"]=>
56 NULL
57 }
58
59 s://u@
60 object(http\Url)#1 (8) {
61 ["scheme"]=>
62 string(1) "s"
63 ["user"]=>
64 string(1) "u"
65 ["pass"]=>
66 NULL
67 ["host"]=>
68 NULL
69 ["port"]=>
70 NULL
71 ["path"]=>
72 NULL
73 ["query"]=>
74 NULL
75 ["fragment"]=>
76 NULL
77 }
78
79 s://u:@
80 object(http\Url)#1 (8) {
81 ["scheme"]=>
82 string(1) "s"
83 ["user"]=>
84 string(1) "u"
85 ["pass"]=>
86 string(0) ""
87 ["host"]=>
88 NULL
89 ["port"]=>
90 NULL
91 ["path"]=>
92 NULL
93 ["query"]=>
94 NULL
95 ["fragment"]=>
96 NULL
97 }
98
99 s://u:p@
100 object(http\Url)#1 (8) {
101 ["scheme"]=>
102 string(1) "s"
103 ["user"]=>
104 string(1) "u"
105 ["pass"]=>
106 string(1) "p"
107 ["host"]=>
108 NULL
109 ["port"]=>
110 NULL
111 ["path"]=>
112 NULL
113 ["query"]=>
114 NULL
115 ["fragment"]=>
116 NULL
117 }
118
119 s://user:pass@
120 object(http\Url)#1 (8) {
121 ["scheme"]=>
122 string(1) "s"
123 ["user"]=>
124 string(4) "user"
125 ["pass"]=>
126 string(4) "pass"
127 ["host"]=>
128 NULL
129 ["port"]=>
130 NULL
131 ["path"]=>
132 NULL
133 ["query"]=>
134 NULL
135 ["fragment"]=>
136 NULL
137 }
138
139 s://user:pass@host
140 object(http\Url)#1 (8) {
141 ["scheme"]=>
142 string(1) "s"
143 ["user"]=>
144 string(4) "user"
145 ["pass"]=>
146 string(4) "pass"
147 ["host"]=>
148 string(4) "host"
149 ["port"]=>
150 NULL
151 ["path"]=>
152 NULL
153 ["query"]=>
154 NULL
155 ["fragment"]=>
156 NULL
157 }
158
159 s://u@h
160 object(http\Url)#1 (8) {
161 ["scheme"]=>
162 string(1) "s"
163 ["user"]=>
164 string(1) "u"
165 ["pass"]=>
166 NULL
167 ["host"]=>
168 string(1) "h"
169 ["port"]=>
170 NULL
171 ["path"]=>
172 NULL
173 ["query"]=>
174 NULL
175 ["fragment"]=>
176 NULL
177 }
178
179 s://user@h
180 object(http\Url)#1 (8) {
181 ["scheme"]=>
182 string(1) "s"
183 ["user"]=>
184 string(4) "user"
185 ["pass"]=>
186 NULL
187 ["host"]=>
188 string(1) "h"
189 ["port"]=>
190 NULL
191 ["path"]=>
192 NULL
193 ["query"]=>
194 NULL
195 ["fragment"]=>
196 NULL
197 }
198
199 s://u@host
200 object(http\Url)#1 (8) {
201 ["scheme"]=>
202 string(1) "s"
203 ["user"]=>
204 string(1) "u"
205 ["pass"]=>
206 NULL
207 ["host"]=>
208 string(4) "host"
209 ["port"]=>
210 NULL
211 ["path"]=>
212 NULL
213 ["query"]=>
214 NULL
215 ["fragment"]=>
216 NULL
217 }
218
219 s://user:p@h
220 object(http\Url)#1 (8) {
221 ["scheme"]=>
222 string(1) "s"
223 ["user"]=>
224 string(4) "user"
225 ["pass"]=>
226 string(1) "p"
227 ["host"]=>
228 string(1) "h"
229 ["port"]=>
230 NULL
231 ["path"]=>
232 NULL
233 ["query"]=>
234 NULL
235 ["fragment"]=>
236 NULL
237 }
238
239 s://user:pass@h
240 object(http\Url)#1 (8) {
241 ["scheme"]=>
242 string(1) "s"
243 ["user"]=>
244 string(4) "user"
245 ["pass"]=>
246 string(4) "pass"
247 ["host"]=>
248 string(1) "h"
249 ["port"]=>
250 NULL
251 ["path"]=>
252 NULL
253 ["query"]=>
254 NULL
255 ["fragment"]=>
256 NULL
257 }
258
259 s://user:pass@host
260 object(http\Url)#1 (8) {
261 ["scheme"]=>
262 string(1) "s"
263 ["user"]=>
264 string(4) "user"
265 ["pass"]=>
266 string(4) "pass"
267 ["host"]=>
268 string(4) "host"
269 ["port"]=>
270 NULL
271 ["path"]=>
272 NULL
273 ["query"]=>
274 NULL
275 ["fragment"]=>
276 NULL
277 }
278 DONE