Merge bitbucket.org:mike_php_net/ext-propro
[m6w6/ext-propro] / tests / 002.phpt
1 --TEST--
2 property proxy
3 --SKIPIF--
4 <?php if (!extension_loaded("propro")) print "skip"; ?>
5 --FILE--
6 <?php
7
8 echo "Test\n";
9
10 class c {
11 private $storage = array();
12 function __get($p) {
13 return new php\PropertyProxy($this->storage, $p);
14 }
15 function __set($p, $v) {
16 $this->storage[$p] = $v;
17 }
18 }
19
20 $c = new c;
21 $c->data["foo"] = 1;
22 var_dump(
23 isset($c->data["foo"]),
24 isset($c->data["bar"])
25 );
26
27 var_dump($c);
28
29 $c->data[] = 1;
30 $c->data[] = 2;
31 $c->data[] = 3;
32 $c->data["bar"][] = 123;
33 $c->data["bar"][] = 456;
34
35 var_dump($c);
36 unset($c->data["bar"][0]);
37
38 var_dump($c);
39
40 ?>
41 DONE
42 --EXPECTF--
43 Test
44 bool(true)
45 bool(false)
46 object(c)#%d (1) {
47 ["storage":"c":private]=>
48 array(1) {
49 ["data"]=>
50 array(1) {
51 ["foo"]=>
52 int(1)
53 }
54 }
55 }
56 object(c)#%d (1) {
57 ["storage":"c":private]=>
58 array(1) {
59 ["data"]=>
60 array(5) {
61 ["foo"]=>
62 int(1)
63 [0]=>
64 int(1)
65 [1]=>
66 int(2)
67 [2]=>
68 int(3)
69 ["bar"]=>
70 array(2) {
71 [0]=>
72 int(123)
73 [1]=>
74 int(456)
75 }
76 }
77 }
78 }
79 object(c)#%d (1) {
80 ["storage":"c":private]=>
81 array(1) {
82 ["data"]=>
83 array(5) {
84 ["foo"]=>
85 int(1)
86 [0]=>
87 int(1)
88 [1]=>
89 int(2)
90 [2]=>
91 int(3)
92 ["bar"]=>
93 array(1) {
94 [1]=>
95 int(456)
96 }
97 }
98 }
99 }
100 DONE