xref: /PHP-5.3/ext/spl/tests/iterator_032.phpt (revision 610c7fbe)
1--TEST--
2SPL: LimitIterator::getPosition()
3--FILE--
4<?php
5
6$it = new LimitIterator(new ArrayIterator(array(1,2,3,4)), 1, 2);
7
8foreach($it as $k=>$v)
9{
10	echo "$k=>$v\n";
11	var_dump($it->getPosition());
12}
13
14try
15{
16	$it->seek(0);
17}
18catch(OutOfBoundsException $e)
19{
20	echo $e->getMessage() . "\n";
21}
22
23$it->seek(2);
24var_dump($it->current());
25
26try
27{
28	$it->seek(3);
29}
30catch(OutOfBoundsException $e)
31{
32	echo $e->getMessage() . "\n";
33}
34
35$it->next();
36var_dump($it->valid());
37
38?>
39===DONE===
40<?php exit(0); ?>
41--EXPECT--
421=>2
43int(1)
442=>3
45int(2)
46Cannot seek to 0 which is below the offset 1
47int(3)
48Cannot seek to 3 which is behind offset 1 plus count 2
49bool(false)
50===DONE===
51