You are here

protected function EnvironmentCleaner::doCleanTemporaryDirectories in Drupal 8

Same name and namespace in other branches
  1. 9 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.

3 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.
EnvironmentCleanerService::cleanTemporaryDirectories in core/modules/simpletest/src/EnvironmentCleanerService.php
Finds all leftover fixture site directories and removes them.

File

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

Class

EnvironmentCleaner
Helper class for cleaning test environments.

Namespace

Drupal\Core\Test

Code

protected function doCleanTemporaryDirectories() {
  $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;
}