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. 11.x 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
EnvironmentCleaner::cleanTemporaryDirectories in core/lib/Drupal/Core/Test/EnvironmentCleaner.php

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.