Annotation of embedaddon/php/ext/spl/tests/iterator_016.phpt, revision 1.1

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

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