xref: /PHP-7.3/ext/spl/tests/bug68825.phpt (revision dc4f4250)
1--TEST--
2Bug #68825 (Exception in DirectoryIterator::getLinkTarget())
3--SKIPIF--
4<?php
5if (PHP_OS_FAMILY === 'Windows') {
6    $fn = "bug68825.lnk";
7    $ret = exec("mklink $fn " . __FILE__ .' 2>&1', $out);
8    @unlink($fn);
9    if (strpos($ret, 'privilege')) {
10        die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
11    }
12}
13?>
14--FILE--
15<?php
16$dir = __DIR__ . '/bug68825';
17mkdir($dir);
18symlink(__FILE__, "$dir/foo");
19
20$di = new \DirectoryIterator($dir);
21foreach ($di as $entry) {
22    if ('foo' === $entry->getFilename()) {
23        var_dump($entry->getLinkTarget());
24    }
25}
26?>
27===DONE===
28--EXPECTF--
29string(%d) "%s%eext%espl%etests%ebug68825.php"
30===DONE===
31--CLEAN--
32<?php
33$dir = __DIR__ . '/bug68825';
34unlink("$dir/foo");
35rmdir($dir);
36?>
37