iterator_032.phpt 659 B

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