You are here

public function EnvironmentCleaner::cleanEnvironment in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::cleanEnvironment()

Removes all test-related database tables and directories.

This method removes fixture files and database entries from the system under test.

Parameters

bool $clear_results: (optional) Whether to clear the test results database. Defaults to TRUE.

bool $clear_temp_directories: (optional) Whether to clear the test site directories. Defaults to TRUE.

bool $clear_database: (optional) Whether to clean up the fixture database. Defaults to TRUE.

Overrides EnvironmentCleanerInterface::cleanEnvironment

1 method overrides EnvironmentCleaner::cleanEnvironment()
EnvironmentCleanerService::cleanEnvironment in core/modules/simpletest/src/EnvironmentCleanerService.php
Removes all test-related database tables and directories.

File

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

Class

EnvironmentCleaner
Helper class for cleaning test environments.

Namespace

Drupal\Core\Test

Code

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