xref: /PHP-8.0/ext/spl/tests/bug70561.phpt (revision 368d3ff0)
1--TEST--
2Bug #70561 (DirectoryIterator::seek should throw OutOfBoundsException)
3--FILE--
4<?php
5$di = new DirectoryIterator(__DIR__ . '/..');
6
7$cnt = 0;
8$di->rewind();
9while ($di->valid()) {
10    $cnt++;
11    $di->next();
12}
13
14try {
15    $di->seek($cnt+1);
16} catch (OutOfBoundsException $ex) {
17    echo $ex->getMessage() . PHP_EOL;
18}
19echo "Is valid? " . (int) $di->valid() . PHP_EOL;
20?>
21--EXPECTF--
22Seek position %d is out of range
23Is valid? 0
24