Annotation of embedaddon/php/ext/spl/tests/iterator_025.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: SPL: RecursiveIteratorIterator and begin/endIteration()
                      3: --FILE--
                      4: <?php
                      5: 
                      6: class MyRecursiveIteratorIterator extends RecursiveIteratorIterator
                      7: {
                      8:        function beginIteration()
                      9:        {
                     10:                echo __METHOD__ . "()\n";
                     11:        }
                     12:        
                     13:        function endIteration()
                     14:        {
                     15:                echo __METHOD__ . "()\n";
                     16:        }
                     17: }
                     18: 
                     19: $ar = array(1, 2, array(31, 32, array(331)), 4);
                     20: 
                     21: $it = new MyRecursiveIteratorIterator(new ArrayObject($ar, 0, "RecursiveArrayIterator"));
                     22: 
                     23: foreach($it as $v) echo "$v\n";
                     24: 
                     25: echo "===MORE===\n";
                     26: 
                     27: foreach($it as $v) echo "$v\n";
                     28: 
                     29: echo "===MORE===\n";
                     30: 
                     31: $it->rewind();
                     32: foreach($it as $v) echo "$v\n";
                     33: var_dump($it->valid());
                     34: 
                     35: echo "===MANUAL===\n";
                     36: 
                     37: $it->rewind();
                     38: while($it->valid())
                     39: {
                     40:        echo $it->current() . "\n";
                     41:        $it->next();
                     42:        break;
                     43: }
                     44: $it->rewind();
                     45: while($it->valid())
                     46: {
                     47:        echo $it->current() . "\n";
                     48:        $it->next();
                     49: }
                     50: 
                     51: ?>
                     52: ===DONE===
                     53: <?php exit(0); ?>
                     54: --EXPECT--
                     55: MyRecursiveIteratorIterator::beginIteration()
                     56: 1
                     57: 2
                     58: 31
                     59: 32
                     60: 331
                     61: 4
                     62: MyRecursiveIteratorIterator::endIteration()
                     63: ===MORE===
                     64: MyRecursiveIteratorIterator::beginIteration()
                     65: 1
                     66: 2
                     67: 31
                     68: 32
                     69: 331
                     70: 4
                     71: MyRecursiveIteratorIterator::endIteration()
                     72: ===MORE===
                     73: MyRecursiveIteratorIterator::beginIteration()
                     74: 1
                     75: 2
                     76: 31
                     77: 32
                     78: 331
                     79: 4
                     80: MyRecursiveIteratorIterator::endIteration()
                     81: bool(false)
                     82: ===MANUAL===
                     83: MyRecursiveIteratorIterator::beginIteration()
                     84: 1
                     85: 1
                     86: 2
                     87: 31
                     88: 32
                     89: 331
                     90: 4
                     91: MyRecursiveIteratorIterator::endIteration()
                     92: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>