php-src/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt

51 lines
1.1 KiB
Plaintext
Raw Normal View History

2012-09-18 21:15:03 +00:00
--TEST--
RecursiveDirectoryIterator::getBasePath() - basic test
--CREDITS--
Pawel Krynicki <pawel [dot] krynicki [at] xsolve [dot] pl>
#testfest AmsterdamPHP 2012-06-23
--FILE--
<?php
$depth0 = "depth0";
$depth1 = 'depth1';
$depth2 = 'depth2';
2012-09-18 21:15:03 +00:00
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . $depth2;
mkdir($targetDir, 0777, true);
touch($targetDir . DIRECTORY_SEPARATOR . 'getSubPath_test.tmp');
$iterator = new RecursiveDirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . $depth0);
$it = new RecursiveIteratorIterator($iterator);
$list = [];
while($it->valid()) {
$list[] = $it->getSubPath();
$it->next();
}
asort($list);
foreach ($list as $item) {
echo $item . "\n";
}
?>
--CLEAN--
<?php
function rrmdir($dir) {
foreach(glob($dir . '/*') as $file) {
if(is_dir($file)) {
2012-09-18 21:15:03 +00:00
rrmdir($file);
} else {
2012-09-18 21:15:03 +00:00
unlink($file);
}
}
2012-09-18 21:15:03 +00:00
rmdir($dir);
}
2012-09-18 21:15:03 +00:00
$targetDir = __DIR__.DIRECTORY_SEPARATOR . "depth0";
rrmdir($targetDir);
2012-09-18 21:15:03 +00:00
?>
2012-09-27 17:52:34 +00:00
--EXPECTF--
depth1
depth1
depth1%cdepth2
depth1%cdepth2
depth1%cdepth2