given( $foobar = $this->getDummyIterator(), $filter = new \Mock\Hoa\Iterator\Test\Unit\MyFilter($foobar), $this->calling($filter)->accept = function () { $value = $this->current(); return false === in_array($value, ['a', 'e', 'i', 'o', 'u']); } ) ->when($result = iterator_to_array($filter)) ->then ->array($result) ->isEqualTo([ 0 => 'f', 3 => 'b', 5 => 'r' ]); } public function case_remove_all() { $this ->given( $foobar = $this->getDummyIterator(), $filter = new \Mock\Hoa\Iterator\Test\Unit\MyFilter($foobar), $this->calling($filter)->accept = false ) ->when($result = iterator_to_array($filter)) ->then ->array($result) ->isEmpty(); } public function case_remove_none() { $this ->given( $foobar = $this->getDummyIterator(), $filter = new MyFilter($foobar) ) ->when( $foobarResult = iterator_to_array($foobar), $filterResult = iterator_to_array($filter) ) ->then ->array($foobarResult) ->isEqualTo($filterResult); } protected function getDummyIterator() { return new LUT\Map(['f', 'o', 'o', 'b', 'a', 'r']); } }