function EnvironmentCleaner::doCleanTemporaryDirectories

Same name in other branches
  1. 9 core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::doCleanTemporaryDirectories()
  2. 8.9.x core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::doCleanTemporaryDirectories()
  3. 10 core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::doCleanTemporaryDirectories()

Performs the cleanup of temporary test directories.

Return value

int The count of temporary directories removed.

2 calls to EnvironmentCleaner::doCleanTemporaryDirectories()
EnvironmentCleaner::cleanEnvironment in core/lib/Drupal/Core/Test/EnvironmentCleaner.php
Removes all test-related database tables and directories.
EnvironmentCleaner::cleanTemporaryDirectories in core/lib/Drupal/Core/Test/EnvironmentCleaner.php
Finds all leftover fixture site directories and removes them.

File

core/lib/Drupal/Core/Test/EnvironmentCleaner.php, line 113

Class

EnvironmentCleaner
Helper class for cleaning test environments.

Namespace

Drupal\Core\Test

Code

protected function doCleanTemporaryDirectories() : int {
    $count = 0;
    $simpletest_dir = $this->root . '/sites/simpletest';
    if (is_dir($simpletest_dir)) {
        $files = scandir($simpletest_dir);
        foreach ($files as $file) {
            if ($file[0] != '.') {
                $path = $simpletest_dir . '/' . $file;
                $this->fileSystem
                    ->deleteRecursive($path, function ($any_path) {
                    @chmod($any_path, 0700);
                });
                $count++;
            }
        }
    }
    return $count;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.