function SimpletestTestRunResultsStorage::buildTestingResultsEnvironment

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Test/SimpletestTestRunResultsStorage.php \Drupal\Core\Test\SimpletestTestRunResultsStorage::buildTestingResultsEnvironment()

Prepares the test run storage.

Parameters

bool $keep_results: If TRUE, any pre-existing storage will be preserved; if FALSE, pre-existing storage will be cleaned up.

Overrides TestRunResultsStorageInterface::buildTestingResultsEnvironment

File

core/lib/Drupal/Core/Test/SimpletestTestRunResultsStorage.php, line 146

Class

SimpletestTestRunResultsStorage
Implements a test run results storage compatible with legacy Simpletest.

Namespace

Drupal\Core\Test

Code

public function buildTestingResultsEnvironment(bool $keep_results) : void {
  $schema = $this->connection
    ->schema();
  foreach (static::testingResultsSchema() as $name => $table_spec) {
    $table_exists = $schema->tableExists($name);
    if (!$keep_results && $table_exists) {
      $this->connection
        ->truncate($name)
        ->execute();
    }
    if (!$table_exists) {
      $schema->createTable($name, $table_spec);
    }
  }
}

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