xref: /php-src/ext/spl/tests/bug51119.phpt (revision 063fdd94)
1--TEST--
2SPL: LimitIterator zero is valid offset
3--FILE--
4<?php
5
6$array = array('a', 'b', 'c');
7$arrayIterator = new ArrayIterator($array);
8
9$limitIterator = new LimitIterator($arrayIterator, 0);
10foreach ($limitIterator as $item) {
11    echo $item . "\n";
12}
13
14try {
15    $limitIterator = new LimitIterator($arrayIterator, -1);
16} catch (\ValueError $e){
17    print $e->getMessage() . "\n";
18}
19
20?>
21--EXPECT--
22a
23b
24c
25LimitIterator::__construct(): Argument #2 ($offset) must be greater than or equal to 0
26