Annotation of embedaddon/php/ext/spl/tests/bug61527.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #61527 (Recursive/ArrayIterator gives misleading notice when array empty or moved to the end)
! 3: --FILE--
! 4: <?php
! 5: $ao = new ArrayObject(array());
! 6: $ai = $ao->getIterator();
! 7:
! 8: /* testing empty array, should no notice at all */
! 9: $ai->next();
! 10: var_dump($ai->key());
! 11: var_dump($ai->current());
! 12:
! 13: /* testing array changing */
! 14: $ao2 = new ArrayObject(array(1 => 1, 2, 3, 4, 5));
! 15: $ai2 = $ao2->getIterator();
! 16:
! 17: $ao2->offsetUnset($ai2->key());
! 18: $ai2->next();
! 19:
! 20: /* now point to 2 */
! 21: $ao2->offsetUnset($ai2->key());
! 22: var_dump($ai2->key());
! 23:
! 24: /* now point to 3 */
! 25: $ao2->offsetUnset($ai2->key());
! 26: var_dump($ai2->current());
! 27:
! 28: $ai2->next();
! 29: var_dump($ai2->key());
! 30: var_dump($ai2->current());
! 31:
! 32: /* should be at the end and no notice */
! 33: $ai2->next();
! 34: var_dump($ai2->key());
! 35: var_dump($ai2->current());
! 36:
! 37: $ai2->rewind();
! 38: $ai2->next();
! 39: $ai2->next();
! 40: /* should reached the end */
! 41: var_dump($ai2->next());
! 42: var_dump($ai2->key());
! 43:
! 44: /* testing RecursiveArrayIterator */
! 45: $ao3 = new ArrayObject(array(), NULL, 'RecursiveArrayIterator');
! 46: $ai3 = $ao3->getIterator();
! 47:
! 48: var_dump($ai3->getChildren());
! 49:
! 50: $ao4 = new ArrayObject(array(1, 2), NULL, 'RecursiveArrayIterator');
! 51: $ai4 = $ao4->getIterator();
! 52:
! 53: $ai4->next();
! 54: $ai4->next();
! 55: $ai4->next();
! 56: var_dump($ai4->hasChildren());
! 57:
! 58: $ai4->rewind();
! 59: $ao4->offsetUnset($ai4->key());
! 60: var_dump($ai4->hasChildren());
! 61:
! 62: $ao4->offsetUnset($ai4->key());
! 63: var_dump($ai4->getChildren());
! 64: ?>
! 65: ==DONE==
! 66: <?php exit(0); ?>
! 67: --EXPECTF--
! 68: NULL
! 69: NULL
! 70:
! 71: Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
! 72:
! 73: Notice: ArrayIterator::key(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
! 74: NULL
! 75:
! 76: Notice: ArrayIterator::current(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
! 77: NULL
! 78: int(5)
! 79: int(5)
! 80: NULL
! 81: NULL
! 82: NULL
! 83: NULL
! 84: NULL
! 85: bool(false)
! 86:
! 87: Notice: RecursiveArrayIterator::hasChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
! 88: bool(false)
! 89:
! 90: Notice: RecursiveArrayIterator::getChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
! 91: NULL
! 92: ==DONE==
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>