public static function TestBase::getDatabaseConnection

Returns the database connection to the site running Simpletest.

Return value

Drupal\Core\Database\Connection The database connection to use for inserting assertions.

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php, line 292
Definition of Drupal\simpletest\TestBase.

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

public static function getDatabaseConnection() {
  try {
    $connection = Database::getConnection('default', 'simpletest_original_default');
  } catch (ConnectionNotDefinedException $e) {

    // If the test was not set up, the simpletest_original_default
    // connection does not exist.
    $connection = Database::getConnection('default', 'default');
  }
  return $connection;
}