function SimpletestTestRunResultsStorage::setDatabasePrefix

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

Overrides TestRunResultsStorageInterface::setDatabasePrefix

File

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

Class

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

Namespace

Drupal\Core\Test

Code

public function setDatabasePrefix(TestRun $test_run, string $database_prefix) : void {
    $affected_rows = $this->connection
        ->update('simpletest_test_id')
        ->fields([
        'last_prefix' => $database_prefix,
    ])
        ->condition('test_id', $test_run->id())
        ->execute();
    if (!$affected_rows) {
        throw new \RuntimeException('Failed to set up database prefix.');
    }
}

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