/** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { if (file_exists($this->rootPath)) { $filesystem = new \Composer\Util\Filesystem(); $filesystem->removeDirectory($this->rootPath); } parent::tearDown(); }
/** * Recursively removes the specified directory or file * * @param $dir */ public static function rmdirRecursive($dir) { $fs = new \Composer\Util\Filesystem(); if (is_dir($dir)) { $result = $fs->removeDirectory($dir); } else { @unlink($dir); } return; }
/** * Recursively removes the specified directory or file * * @param $dir * @return bool */ public static function rmdirRecursive($dir) { $fs = new \Composer\Util\Filesystem(); return $fs->removeDirectory($dir); /* if (is_dir($dir) && ! is_link($dir)) { $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $item) { $path = (string) $item; if (!strcmp($path, '.') || !strcmp($path, '..')) { continue; } if (is_dir($path)) { self::rmdirRecursive($path); } else { @unlink($path); } } $result = @rmdir($dir); } else { $result = @unlink($dir); } return $result; */ }