Annotation of embedaddon/php/ext/spl/tests/observer_005.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: SplObjectStorage serialization & visibility
3: --FILE--
4: <?php
5:
6: class TestClass
7: {
8: public $def = 24;
9: public $pub = 25;
10: protected $pro = 26;
11: private $pri = 27;
12:
13: public function __construct($pub = 42, $pro = 43, $pri = 44)
14: {
15: $this->pub = $pub;
16: $this->pro = $pro;
17: $this->pri = $pri;
18: }
19: }
20:
21: class ExtTestClass
22: {
23: }
24:
25: class MyStorage extends SplObjectStorage
26: {
27: public $def = 24;
28: public $pub = 25;
29: protected $pro = 26;
30: private $pri = 27;
31:
32: public function __construct($pub = 52, $pro = 53, $pri = 54)
33: {
34: $this->pub = $pub;
35: $this->pro = $pro;
36: $this->pri = $pri;
37: }
38: }
39:
40: class ExtStorage extends MyStorage
41: {
42: }
43:
44: $storage = new MyStorage(1,2,3);
45:
46: foreach(array(array(4,5,6),array(7,8,9)) as $value)
47: {
48: $storage->attach(new TestClass($value[0], $value[1], $value[2]));
49: }
50:
51: var_dump(count($storage));
52:
53: foreach($storage as $object)
54: {
55: var_dump($object);
56: }
57:
58: var_dump($storage);
59:
60: var_dump(serialize($storage));
61: echo "===UNSERIALIZE===\n";
62:
63: $storage2 = unserialize(serialize($storage));
64:
65: var_dump(count($storage2));
66:
67: foreach($storage2 as $object)
68: {
69: var_dump($object);
70: }
71:
72: var_dump($storage2);
73:
74: ?>
75: ===DONE===
76: <?php exit(0); ?>
77: --EXPECTF--
78: int(2)
79: object(TestClass)#%d (4) {
80: ["def"]=>
81: int(24)
82: ["pub"]=>
83: int(4)
84: ["pro":protected]=>
85: int(5)
86: ["pri":"TestClass":private]=>
87: int(6)
88: }
89: object(TestClass)#%d (4) {
90: ["def"]=>
91: int(24)
92: ["pub"]=>
93: int(7)
94: ["pro":protected]=>
95: int(8)
96: ["pri":"TestClass":private]=>
97: int(9)
98: }
99: object(MyStorage)#%d (5) {
100: ["def"]=>
101: int(24)
102: ["pub"]=>
103: int(1)
104: ["pro":protected]=>
105: int(2)
106: ["pri":"MyStorage":private]=>
107: int(3)
108: ["storage":"SplObjectStorage":private]=>
109: array(2) {
110: ["%s"]=>
111: array(2) {
112: ["obj"]=>
113: object(TestClass)#%d (4) {
114: ["def"]=>
115: int(24)
116: ["pub"]=>
117: int(4)
118: ["pro":protected]=>
119: int(5)
120: ["pri":"TestClass":private]=>
121: int(6)
122: }
123: ["inf"]=>
124: NULL
125: }
126: ["%s"]=>
127: array(2) {
128: ["obj"]=>
129: object(TestClass)#%d (4) {
130: ["def"]=>
131: int(24)
132: ["pub"]=>
133: int(7)
134: ["pro":protected]=>
135: int(8)
136: ["pri":"TestClass":private]=>
137: int(9)
138: }
139: ["inf"]=>
140: NULL
141: }
142: }
143: }
144: string(%d) "%s"
145: ===UNSERIALIZE===
146: int(2)
147: object(TestClass)#%d (4) {
148: ["def"]=>
149: int(24)
150: ["pub"]=>
151: int(4)
152: ["pro":protected]=>
153: int(5)
154: ["pri":"TestClass":private]=>
155: int(6)
156: }
157: object(TestClass)#%d (4) {
158: ["def"]=>
159: int(24)
160: ["pub"]=>
161: int(7)
162: ["pro":protected]=>
163: int(8)
164: ["pri":"TestClass":private]=>
165: int(9)
166: }
167: object(MyStorage)#%d (5) {
168: ["def"]=>
169: int(24)
170: ["pub"]=>
171: int(1)
172: ["pro":protected]=>
173: int(2)
174: ["pri":"MyStorage":private]=>
175: int(3)
176: ["storage":"SplObjectStorage":private]=>
177: array(2) {
178: ["%s"]=>
179: array(2) {
180: ["obj"]=>
181: object(TestClass)#%d (4) {
182: ["def"]=>
183: int(24)
184: ["pub"]=>
185: int(4)
186: ["pro":protected]=>
187: int(5)
188: ["pri":"TestClass":private]=>
189: int(6)
190: }
191: ["inf"]=>
192: NULL
193: }
194: ["%s"]=>
195: array(2) {
196: ["obj"]=>
197: object(TestClass)#%d (4) {
198: ["def"]=>
199: int(24)
200: ["pub"]=>
201: int(7)
202: ["pro":protected]=>
203: int(8)
204: ["pri":"TestClass":private]=>
205: int(9)
206: }
207: ["inf"]=>
208: NULL
209: }
210: }
211: }
212: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>