function EnvironmentCleaner::cleanEnvironment

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

Overrides EnvironmentCleanerInterface::cleanEnvironment

File

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

Class

EnvironmentCleaner
Helper class for cleaning test environments.

Namespace

Drupal\Core\Test

Code

public function cleanEnvironment(bool $clear_results = TRUE, bool $clear_temp_directories = TRUE, bool $clear_database = TRUE) : void {
    $count = 0;
    if ($clear_database) {
        $this->doCleanDatabase();
    }
    if ($clear_temp_directories) {
        $this->doCleanTemporaryDirectories();
    }
    if ($clear_results) {
        $count = $this->cleanResults();
        $this->output
            ->write('Test results removed: ' . $count);
    }
    else {
        $this->output
            ->write('Test results were not removed.');
    }
}

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