mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Fixing TMP cleanup code in FolderTest
This commit is contained in:
parent
2bb4ed01be
commit
8450b8bbc4
1 changed files with 17 additions and 9 deletions
|
@ -58,9 +58,17 @@ class FolderTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
$exclude = array_merge(self::$_tmp, array('.', '..'));
|
$exclude = array_merge(self::$_tmp, array('.', '..'));
|
||||||
foreach (scandir(TMP) as $file) {
|
foreach (scandir(TMP) as $dir) {
|
||||||
if (is_dir(TMP . $file) && !in_array($file, $exclude)) {
|
if (is_dir(TMP . $dir) && !in_array($dir, $exclude)) {
|
||||||
unlink(TMP . $file);
|
$iterator = new RecursiveDirectoryIterator(TMP . $dir);
|
||||||
|
foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
|
||||||
|
if ($file->isFile() || $file->isLink()) {
|
||||||
|
unlink($file->getPathname());
|
||||||
|
} elseif ($file->isDir() && !in_array($file->getFilename(), array('.', '..'))) {
|
||||||
|
rmdir($file->getPathname());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rmdir(TMP . $dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue