xref: /PHP-5.3/ext/spl/tests/bug51119.phpt (revision fbbe3e36)
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
9try {
10  $limitIterator = new LimitIterator($arrayIterator, 0);
11  foreach ($limitIterator as $item) {
12    echo $item . "\n";
13  }
14} catch (OutOfRangeException $e){
15  print $e->getMessage() . "\n";
16}
17
18try {
19  $limitIterator = new LimitIterator($arrayIterator, -1);
20  foreach ($limitIterator as $item) {
21    echo $item . "\n";
22  }
23} catch (OutOfRangeException $e){
24  print $e->getMessage() . "\n";
25}
26
27?>
28===DONE===
29--EXPECT--
30a
31b
32c
33Parameter offset must be >= 0
34===DONE===
35