coverity fix
[m6w6/ext-http] / tests / params004.phpt
1 --TEST--
2 custom params
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 ?>
7 --FILE--
8 <?php
9 echo "Test\n";
10
11 $s = "foo bar.arg:0.bla gotit:0.now";
12 $p = new http\Params($s, " ", ".", ":");
13 $c = $s;
14 $k = array("foo", "bar", "gotit");
15 $a = array("foo"=>"arg", "bar"=>"bla", "gotit"=>"now");
16 $r = array (
17 'foo' =>
18 array (
19 'value' => true,
20 'arguments' =>
21 array (
22 ),
23 ),
24 'bar' =>
25 array (
26 'value' => true,
27 'arguments' =>
28 array (
29 'arg' => '0',
30 'bla' => true,
31 ),
32 ),
33 'gotit' =>
34 array (
35 'value' => '0',
36 'arguments' =>
37 array (
38 'now' => true,
39 ),
40 ),
41 );
42
43 # ---
44
45 var_dump(count($p->params));
46
47 echo "key exists\n";
48 foreach ($k as $key) {
49 var_dump(array_key_exists($key, $p->params));
50 }
51
52 echo "values\n";
53 foreach ($k as $key) {
54 var_dump($p[$key]["value"]);
55 }
56
57 echo "args\n";
58 foreach ($k as $key) {
59 var_dump(count($p[$key]["arguments"]));
60 }
61
62 echo "arg values\n";
63 foreach ($k as $key) {
64 var_dump(@$p[$key]["arguments"][$a[$key]]);
65 }
66
67 echo "equals\n";
68 var_dump($c === (string) $p);
69 var_dump($r === $p->params);
70 $x = new http\Params($p->params);
71 var_dump($r === $x->toArray());
72 ?>
73 DONE
74 --EXPECT--
75 Test
76 int(3)
77 key exists
78 bool(true)
79 bool(true)
80 bool(true)
81 values
82 bool(true)
83 bool(true)
84 string(1) "0"
85 args
86 int(0)
87 int(2)
88 int(1)
89 arg values
90 NULL
91 bool(true)
92 bool(true)
93 equals
94 bool(true)
95 bool(true)
96 bool(true)
97 DONE