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

1.1       misho       1: --TEST--
                      2: SPL: RecursiveIteratorIterator and beginChildren/endChildren
                      3: --FILE--
                      4: <?php
                      5: 
                      6: class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
                      7: {
                      8:        function rewind()
                      9:        {
                     10:                echo "<ul>\n";
                     11:                parent::rewind();
                     12:        }
                     13:        function beginChildren()
                     14:        {
                     15:                echo str_repeat('  ',$this->getDepth())."<ul>\n";
                     16:        }
                     17: 
                     18:        function endChildren()
                     19:        {
                     20:                echo str_repeat('  ',$this->getDepth())."</ul>\n";
                     21:        }
                     22:        function valid()
                     23:        {
                     24:                if (!parent::valid()) {
                     25:                        echo "<ul>\n";
                     26:                        return false;
                     27:                }
                     28:                return true;
                     29:        }
                     30: }
                     31: 
                     32: $arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d");
                     33: $obj = new RecursiveArrayIterator($arr);
                     34: $rit = new RecursiveArrayIteratorIterator($obj);
                     35: foreach($rit as $k=>$v)
                     36: {
                     37:        echo str_repeat('  ',$rit->getDepth()+1)."$k=>$v\n";
                     38: }
                     39: ?>
                     40: ===DONE===
                     41: <?php exit(0); ?>
                     42: --EXPECTF--
                     43: <ul>
                     44:   0=>a
                     45:   <ul>
                     46:     0=>ba
                     47:     <ul>
                     48:       0=>bba
                     49:       1=>bbb
                     50:     </ul>
                     51:     <ul>
                     52:       <ul>
                     53:         0=>bcaa
                     54:       </ul>
                     55:     </ul>
                     56:   </ul>
                     57:   <ul>
                     58:     0=>ca
                     59:   </ul>
                     60:   3=>d
                     61: <ul>
                     62: ===DONE===

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