given($iterator = new LUT\Map(self::$_dummyArray)) ->when($result = iterator_to_array($iterator)) ->then ->array($result) ->isEqualTo(self::$_dummyArray); } public function case_empty() { $this ->given($iterator = new LUT\Map()) ->when($result = iterator_to_array($iterator)) ->then ->array($result) ->isEmpty(); } public function case_recursive() { $this ->given( $array = [ 'a' => ['b', 'c', 'd'], 'e' => ['f', 'g', 'i'], 'k' ], $iterator = new LUT\Recursive\Map($array) ) ->when(function () use ($iterator) { foreach ($iterator as $key => $value) { if ('a' === $key) { $this ->boolean($iterator->hasChildren()) ->isTrue() ->object($children = $iterator->getChildren()) ->isInstanceOf(LUT\Recursive\Map::class) ->array(iterator_to_array($children)) ->isEqualTo(['b', 'c', 'd']); } elseif ('e' === $key) { $this ->boolean($iterator->hasChildren()) ->isTrue() ->object($children = $iterator->getChildren()) ->isInstanceOf(LUT\Recursive\Map::class) ->array(iterator_to_array($children)) ->isEqualTo(['f', 'g', 'i']); } elseif ('k' === $value) { $this ->boolean($iterator->hasChildren()) ->isFalse(); } } }); } }