From aad99f5eaa332d6d2c54fb50f475a3623d12fef5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 8 Oct 2024 19:09:43 +0300 Subject: [PATCH] A new fix in test --- tests/ActionTest.php | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/tests/ActionTest.php b/tests/ActionTest.php index 5ab3098..d135b89 100644 --- a/tests/ActionTest.php +++ b/tests/ActionTest.php @@ -64,28 +64,25 @@ private function removeDirectory(string $dir): void { $dir = realpath($dir); - if (is_dir($dir) && is_readable($dir) && is_writable($dir)) { + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($dir), + \RecursiveIteratorIterator::CHILD_FIRST, + ); - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($dir), - \RecursiveIteratorIterator::CHILD_FIRST, - ); + foreach ($iterator as $path) { - foreach ($iterator as $path) { - - if (!$path instanceof \SplFileInfo) { - continue; - } - - if ($path->isDir()) { - rmdir((string) $path); - } else { - unlink((string) $path); - } + if (!$path instanceof \SplFileInfo) { + continue; } - rmdir($dir); + if ($path->isDir()) { + rmdir((string) $path); + } else { + unlink((string) $path); + } } + + rmdir($dir); } public function testBuildComposerPackage(): void