function EnvironmentCleanerService::cleanEnvironment

Overrides EnvironmentCleaner::cleanEnvironment

File

core/modules/simpletest/src/EnvironmentCleanerService.php, line 74

Class

EnvironmentCleanerService
Uses containerized services to perform post-test cleanup.

Namespace

Drupal\simpletest

Code

public function cleanEnvironment($clear_results = TRUE, $clear_temp_directories = TRUE, $clear_database = TRUE) {
    $results_removed = 0;
    $clear_results = $this->configFactory
        ->get('simpletest.settings')
        ->get('clear_results');
    if ($clear_database) {
        $this->cleanDatabase();
    }
    if ($clear_temp_directories) {
        $this->cleanTemporaryDirectories();
    }
    if ($clear_results) {
        $results_removed = $this->cleanResultsTable();
    }
    $this->cacheDefault
        ->delete('simpletest');
    $this->cacheDefault
        ->delete('simpletest_phpunit');
    if ($clear_results) {
        $this->messenger
            ->addMessage($this->translation
            ->formatPlural($results_removed, 'Removed 1 test result.', 'Removed @count test results.'));
    }
    else {
        $this->messenger
            ->addMessage($this->translation
            ->translate('Clear results is disabled and the test results table will not be cleared.'), 'warning');
    }
}

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