Annotation of embedaddon/php/ext/spl/tests/iterator_046.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SPL: CachingIterator and __toString using bypassed string keys
! 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 fill()
! 22: {
! 23: echo __METHOD__ . "()\n";
! 24: foreach($this as $v) ;
! 25: }
! 26:
! 27: function show()
! 28: {
! 29: echo __METHOD__ . "()\n";
! 30: foreach($this as $v)
! 31: {
! 32: var_dump((string)$this);
! 33: }
! 34: }
! 35: }
! 36:
! 37: $it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 'bar'=>2)), CachingIterator::TOSTRING_USE_KEY);
! 38:
! 39: $it->fill();
! 40: $it->show();
! 41:
! 42: ?>
! 43: ===DONE===
! 44: <?php exit(0); ?>
! 45: --EXPECTF--
! 46: MyCachingIterator::fill()
! 47: MyCachingIterator::show()
! 48: string(1) "0"
! 49: string(3) "foo"
! 50: string(3) "bar"
! 51: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>