TQ\Tests\Helper::removeDirectory PHP Method

removeDirectory() public static method

public static removeDirectory ( string $path )
$path string
    public static function removeDirectory($path)
    {
        clearstatcache();
        if (!file_exists($path)) {
            return;
        }
        if (!is_dir($path)) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a directory', $path));
        }
        $dirIt = new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::UNIX_PATHS);
        $it = new \RecursiveIteratorIterator($dirIt, \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($it as $p => $f) {
            /** @var $f \SplFileInfo */
            if ($f->isDir()) {
                rmdir($p);
            } else {
                if ($f->isFile()) {
                    chmod($p, 0777);
                    unlink($p);
                }
            }
        }
        rmdir($path);
        $svnRepoPath = dirname($path) . '/' . basename($path) . '_repo';
        if (file_exists($svnRepoPath)) {
            self::removeDirectory($svnRepoPath);
        }
    }

Usage Example

コード例 #1
0
ファイル: FileReadTest.php プロジェクト: awwong1/esps-wpsite
 /**
  * Tears down the fixture, for example, close a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     Helper::removeDirectory(TESTS_TMP_PATH);
     StreamWrapper::unregister();
 }
All Usage Examples Of TQ\Tests\Helper::removeDirectory