Annotation of embedaddon/php/ext/spl/tests/iterator_044.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: CachingIterator and offsetGet/Exists using flag FULL_CACHE
3: --FILE--
4: <?php
5:
6: class MyFoo
7: {
8: function __toString()
9: {
10: return 'foo';
11: }
12: }
13:
14: class MyCachingIterator extends CachingIterator
15: {
16: function __construct(Iterator $it, $flags = 0)
17: {
18: parent::__construct($it, $flags);
19: }
20:
21: function test($ar)
22: {
23: foreach($ar as $k => $v)
24: {
25: echo "===$k===\n";
26: var_dump($v);
27: var_dump($this->offsetExists($v));
28: var_dump($this->offsetGet($v));
29: }
30: }
31: }
32:
33: $it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4)));
34:
35: try
36: {
37: var_dump($it->offsetExists(0));
38: }
39: catch(Exception $e)
40: {
41: echo "Exception: " . $e->getMessage() . "\n";
42: }
43:
44: try
45: {
46: var_dump($it->offsetGet(0));
47: }
48: catch(Exception $e)
49: {
50: echo "Exception: " . $e->getMessage() . "\n";
51: }
52:
53: $it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4)), CachingIterator::FULL_CACHE);
54:
55: var_dump($it->offsetExists());
56: var_dump($it->offsetGet());
57:
58: $checks = array(0, new stdClass, new MyFoo, NULL, 2, 'foo', 3);
59:
60: $it->test($checks);
61:
62: echo "===FILL===\n";
63:
64: foreach($it as $v); // read all into cache
65:
66: $it->test($checks);
67:
68: ?>
69: ===DONE===
70: <?php exit(0); ?>
71: --EXPECTF--
72: Exception: MyCachingIterator does not use a full cache (see CachingIterator::__construct)
73: Exception: MyCachingIterator does not use a full cache (see CachingIterator::__construct)
74:
75: Warning: CachingIterator::offsetExists() expects exactly 1 parameter, 0 given in %siterator_044.php on line %d
76: NULL
77:
78: Warning: CachingIterator::offsetGet() expects exactly 1 parameter, 0 given in %siterator_044.php on line %d
79: NULL
80: ===0===
81: int(0)
82: bool(false)
83:
84: Notice: Undefined index: 0 in %siterator_044.php on line %d
85: NULL
86: ===1===
87: object(stdClass)#%d (0) {
88: }
89:
90: Warning: CachingIterator::offsetExists() expects parameter 1 to be string, object given in %siterator_044.php on line %d
91: NULL
92:
93: Warning: CachingIterator::offsetGet() expects parameter 1 to be string, object given in %siterator_044.php on line %d
94: NULL
95: ===2===
96: object(MyFoo)#%d (0) {
97: }
98: bool(false)
99:
100: Notice: Undefined index: foo in %siterator_044.php on line %d
101: NULL
102: ===3===
103: NULL
104: bool(false)
105:
106: Notice: Undefined index: in %siterator_044.php on line %d
107: NULL
108: ===4===
109: int(2)
110: bool(false)
111:
112: Notice: Undefined index: 2 in %siterator_044.php on line %d
113: NULL
114: ===5===
115: string(3) "foo"
116: bool(false)
117:
118: Notice: Undefined index: foo in %siterator_044.php on line %d
119: NULL
120: ===6===
121: int(3)
122: bool(false)
123:
124: Notice: Undefined index: 3 in %siterator_044.php on line %d
125: NULL
126: ===FILL===
127: ===0===
128: int(0)
129: bool(true)
130: int(0)
131: ===1===
132: object(stdClass)#1 (0) {
133: }
134:
135: Warning: CachingIterator::offsetExists() expects parameter 1 to be string, object given in %siterator_044.php on line %d
136: NULL
137:
138: Warning: CachingIterator::offsetGet() expects parameter 1 to be string, object given in %siterator_044.php on line %d
139: NULL
140: ===2===
141: object(MyFoo)#2 (0) {
142: }
143: bool(true)
144: int(1)
145: ===3===
146: NULL
147: bool(false)
148:
149: Notice: Undefined index: in %siterator_044.php on line %d
150: NULL
151: ===4===
152: int(2)
153: bool(true)
154: int(4)
155: ===5===
156: string(3) "foo"
157: bool(true)
158: int(1)
159: ===6===
160: int(3)
161: bool(false)
162:
163: Notice: Undefined index: 3 in %siterator_044.php on line %d
164: NULL
165: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>