Annotation of embedaddon/php/ext/spl/tests/iterator_042.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: AppendIterator and its ArrayIterator
3: --FILE--
4: <?php
5:
6: function test_error_handler($errno, $msg, $filename, $linenum, $vars)
7: {
8: echo "Error $msg in $filename on line $linenum\n";
9: return true;
10: }
11:
12: set_error_handler('test_error_handler');
13:
14: $it = new AppendIterator;
15:
16: $it->append(array());
17: $it->append(new ArrayIterator(array(1)));
18: $it->append(new ArrayIterator(array(21, 22)));
19:
20: var_dump($it->getArrayIterator());
21:
22: $it->append(new ArrayIterator(array(31, 32, 33)));
23:
24: var_dump($it->getArrayIterator());
25:
26: $idx = 0;
27:
28: foreach($it as $k => $v)
29: {
30: echo '===' . $idx++ . "===\n";
31: var_dump($it->getIteratorIndex());
32: var_dump($k);
33: var_dump($v);
34: }
35:
36: ?>
37: ===DONE===
38: <?php exit(0); ?>
39: --EXPECTF--
40: Error Argument 1 passed to AppendIterator::append() must implement interface Iterator, array given in %siterator_042.php on line %d
41: object(ArrayIterator)#%d (1) {
42: %s"storage"%s"ArrayIterator":private]=>
43: array(2) {
44: [0]=>
45: object(ArrayIterator)#%d (1) {
46: %s"storage"%s"ArrayIterator":private]=>
47: array(1) {
48: [0]=>
49: int(1)
50: }
51: }
52: [1]=>
53: object(ArrayIterator)#%d (1) {
54: %s"storage"%s"ArrayIterator":private]=>
55: array(2) {
56: [0]=>
57: int(21)
58: [1]=>
59: int(22)
60: }
61: }
62: }
63: }
64: object(ArrayIterator)#%d (1) {
65: %s"storage"%s"ArrayIterator":private]=>
66: array(3) {
67: [0]=>
68: object(ArrayIterator)#%d (1) {
69: %s"storage"%s"ArrayIterator":private]=>
70: array(1) {
71: [0]=>
72: int(1)
73: }
74: }
75: [1]=>
76: object(ArrayIterator)#%d (1) {
77: %s"storage"%s"ArrayIterator":private]=>
78: array(2) {
79: [0]=>
80: int(21)
81: [1]=>
82: int(22)
83: }
84: }
85: [2]=>
86: object(ArrayIterator)#5 (1) {
87: %s"storage"%s"ArrayIterator":private]=>
88: array(3) {
89: [0]=>
90: int(31)
91: [1]=>
92: int(32)
93: [2]=>
94: int(33)
95: }
96: }
97: }
98: }
99: ===0===
100: int(0)
101: int(0)
102: int(1)
103: ===1===
104: int(1)
105: int(0)
106: int(21)
107: ===2===
108: int(1)
109: int(1)
110: int(22)
111: ===3===
112: int(2)
113: int(0)
114: int(31)
115: ===4===
116: int(2)
117: int(1)
118: int(32)
119: ===5===
120: int(2)
121: int(2)
122: int(33)
123: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>