given( $iterator = new LUT\Map([]), $iteratoriterator = new LUT\IteratorIterator($iterator) ) ->when($result = $iteratoriterator->getInnerIterator()) ->then ->object($result) ->isIdenticalTo($iterator); } public function case_traverse() { $this ->given( $iterator = new LUT\Map(['a', 'b', 'c']), $iteratoriterator = new LUT\IteratorIterator($iterator) ) ->when($result = iterator_to_array($iteratoriterator)) ->then ->array($result) ->isEqualTo(['a', 'b', 'c']); } public function case_recursive_leaves_only() { $this ->given( $array = [ 'a' => ['b', 'c', 'd'], 'e' => ['f', 'g', 'i'] ], $iterator = new LUT\Recursive\Map($array), $iteratoriterator = new LUT\Recursive\Iterator( $iterator, LUT\Recursive\Iterator::LEAVES_ONLY ) ) ->when($result = iterator_to_array($iteratoriterator, false)) ->then ->array($result) ->isEqualTo(['b', 'c', 'd', 'f', 'g', 'i']); } public function case_recursive_self_first() { $this ->given( $array = [ 'a' => ['b', 'c', 'd'], 'e' => ['f', 'g', 'i'] ], $iterator = new LUT\Recursive\Map($array), $iteratoriterator = new LUT\Recursive\Iterator( $iterator, LUT\Recursive\Iterator::SELF_FIRST ) ) ->when($result = iterator_to_array($iteratoriterator, false)) ->then ->array($result) ->isEqualTo([ ['b', 'c', 'd'], 'b', 'c', 'd', ['f', 'g', 'i'], 'f', 'g', 'i' ]); } public function case_recursive_child_first() { $this ->given( $array = [ 'a' => ['b', 'c', 'd'], 'e' => ['f', 'g', 'i'] ], $iterator = new LUT\Recursive\Map($array), $iteratoriterator = new LUT\Recursive\Iterator( $iterator, LUT\Recursive\Iterator::CHILD_FIRST ) ) ->when($result = iterator_to_array($iteratoriterator, false)) ->then ->array($result) ->isEqualTo([ 'b', 'c', 'd', ['b', 'c', 'd'], 'f', 'g', 'i', ['f', 'g', 'i'] ]); } }