- changelog
[m6w6/ext-http] / tests / HttpQueryString_001.phpt
1 --TEST--
2 HttpQueryString global
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkmin(5.1);
7 ?>
8 --FILE--
9 <?php
10 echo "-TEST\n";
11
12 $_GET = array('a'=>'b','c'=>'3.4','r'=>array(1,2,3));
13 $_SERVER['QUERY_STRING'] = 'a=b&c=3.4&r[0]=1&r[1]=2&r[2]=3';
14
15 var_dump(HttpQueryString::singleton()->get());
16 var_dump(HttpQueryString::singleton()->get('n'));
17 var_dump(HttpQueryString::singleton()->get('a'));
18 var_dump(HttpQueryString::singleton()->get('a', "i", 0, true));
19 var_dump(HttpQueryString::singleton()->get('a', "string", 'hi!'));
20 var_dump(HttpQueryString::singleton()->get('c'));
21 var_dump(HttpQueryString::singleton()->get('c', HttpQueryString::TYPE_INT));
22 var_dump(HttpQueryString::singleton()->get('c', HttpQueryString::TYPE_FLOAT));
23 var_dump(HttpQueryString::singleton()->get('c', HttpQueryString::TYPE_BOOL));
24 var_dump(HttpQueryString::singleton()->get('r'));
25 var_dump(HttpQueryString::singleton()->get('r', HttpQueryString::TYPE_ARRAY));
26 var_dump(HttpQueryString::singleton()->get('r', HttpQueryString::TYPE_OBJECT));
27
28 HttpQueryString::singleton()->set(new HttpQueryString(false, 'z[0]=2'));
29
30 HttpQueryString::singleton()->set(array('a'=>'b', 'c'=> "3.4"));
31 HttpQueryString::singleton()->set(array('a' => NULL));
32
33 var_dump(HttpQueryString::singleton());
34 var_dump($_GET);
35 var_dump($_SERVER['QUERY_STRING']);
36
37 echo "Done\n";
38 ?>
39 --EXPECTF--
40 %sTEST
41 string(42) "a=b&c=3.4&r%5B0%5D=1&r%5B1%5D=2&r%5B2%5D=3"
42 NULL
43 string(1) "b"
44 int(0)
45 string(3) "hi!"
46 string(3) "3.4"
47 int(3)
48 float(3.4)
49 bool(true)
50 array(3) {
51 [0]=>
52 int(1)
53 [1]=>
54 int(2)
55 [2]=>
56 int(3)
57 }
58 array(3) {
59 [0]=>
60 int(1)
61 [1]=>
62 int(2)
63 [2]=>
64 int(3)
65 }
66 object(stdClass)#%d (%d) {
67 [0]=>
68 int(1)
69 [1]=>
70 int(2)
71 [2]=>
72 int(3)
73 }
74 object(HttpQueryString)#1 (2) {
75 ["queryArray:private"]=>
76 &array(3) {
77 ["c"]=>
78 string(3) "3.4"
79 ["r"]=>
80 array(3) {
81 [0]=>
82 int(1)
83 [1]=>
84 int(2)
85 [2]=>
86 int(3)
87 }
88 ["z"]=>
89 array(1) {
90 [0]=>
91 string(1) "2"
92 }
93 }
94 ["queryString:private"]=>
95 &string(49) "c=3.4&r%5B0%5D=1&r%5B1%5D=2&r%5B2%5D=3&z%5B0%5D=2"
96 }
97 array(3) {
98 ["c"]=>
99 string(3) "3.4"
100 ["r"]=>
101 array(3) {
102 [0]=>
103 int(1)
104 [1]=>
105 int(2)
106 [2]=>
107 int(3)
108 }
109 ["z"]=>
110 array(1) {
111 [0]=>
112 string(1) "2"
113 }
114 }
115 string(49) "c=3.4&r%5B0%5D=1&r%5B1%5D=2&r%5B2%5D=3&z%5B0%5D=2"
116 Done