1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 17:52:16 +01:00
Files
archived-php-src/ext/spl/tests/RecursiveDirectoryIterator_hasChildren.phpt
Cameron Porter 24e7299c9d Fixed bug #80724
FilesystemIterator::FOLLOW_SYMLINKS is currently treated as a directory
key mode flag, even though it does not change the way that the key
during iteration is set. To address this, FOLLOW_SYMLINKS has been
converted into an OTHER flag.

Closes GH-6695.
2021-02-23 09:50:36 +01:00

36 lines
900 B
PHP

--TEST--
SPL: RecursiveDirectoryIterator::hasChildren() follow symlinks test
--FILE--
<?php
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'symlinktest';
if (!mkdir($dir)) {
die('Failed to create temporary directory for testing');
} elseif (!symlink(__DIR__, $dir . DIRECTORY_SEPARATOR . 'symlink')) {
die('Failed to create symbolic link');
}
$it = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS | FilesystemIterator::FOLLOW_SYMLINKS | FilesystemIterator::KEY_AS_FILENAME);
var_dump($it->key());
var_dump($it->hasChildren());
$it->setFlags(FilesystemIterator::SKIP_DOTS | FilesystemIterator::KEY_AS_FILENAME);
var_dump($it->key());
var_dump($it->hasChildren());
?>
--EXPECT--
string(7) "symlink"
bool(true)
string(7) "symlink"
bool(false)
--CLEAN--
<?php
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'symlinktest';
unlink($dir . DIRECTORY_SEPARATOR . 'symlink');
rmdir($dir);
?>