芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/rentandbuyrealty.com/pay/vendor/hoa/iterator/Test/Unit/Lookahead.php
given( $iterator = new LUT\Map(['a', 'b', 'c']), $lookahead = new LUT\Lookahead($iterator) ) ->when($result = iterator_to_array($iterator)) ->then ->array($result) ->isEqualTo(['a', 'b', 'c']); } public function case_check_ahead() { $this ->given( $iterator = new LUT\Map(['a', 'b', 'c']), $lookahead = new LUT\Lookahead($iterator) ) ->when( $lookahead->rewind(), $key = $lookahead->key(), $current = $lookahead->current(), $hasNext = $lookahead->hasNext(), $next = $lookahead->getNext() ) ->then ->integer($key) ->isEqualTo(0) ->string($current) ->isEqualTo('a') ->boolean($hasNext) ->isTrue() ->string($next) ->isEqualTo('b') ->when( $lookahead->next(), $key = $lookahead->key(), $current = $lookahead->current(), $hasNext = $lookahead->hasNext(), $next = $lookahead->getNext() ) ->then ->integer($key) ->isEqualTo(1) ->string($current) ->isEqualTo('b') ->boolean($hasNext) ->isTrue() ->string($next) ->isEqualTo('c') ->when( $lookahead->next(), $key = $lookahead->key(), $current = $lookahead->current(), $hasNext = $lookahead->hasNext(), $next = $lookahead->getNext() ) ->then ->integer($key) ->isEqualTo(2) ->string($current) ->isEqualTo('c') ->boolean($hasNext) ->isFalse() ->variable($next) ->isNull(); } public function case_double_rewind() { $this ->given( $iterator = new LUT\Map(['a', 'b', 'c']), $lookahead = new LUT\Lookahead($iterator) ) ->when( $lookahead->rewind(), $key = $lookahead->key(), $current = $lookahead->current(), $hasNext = $lookahead->hasNext(), $next = $lookahead->getNext() ) ->then ->integer($key) ->isEqualTo(0) ->string($current) ->isEqualTo('a') ->boolean($hasNext) ->isTrue() ->string($next) ->isEqualTo('b') ->when( $lookahead->rewind(), $key = $lookahead->key(), $current = $lookahead->current(), $hasNext = $lookahead->hasNext(), $next = $lookahead->getNext() ) ->then ->integer($key) ->isEqualTo(0) ->string($current) ->isEqualTo('a') ->boolean($hasNext) ->isTrue() ->string($next) ->isEqualTo('b'); } public function case_empty() { $this ->given( $iterator = new LUT\Mock(), $lookahead = new LUT\Lookahead($iterator) ) ->when( $lookahead->rewind(), $valid = $lookahead->valid() ) ->then ->boolean($valid) ->isFalse(); } }