function DrupalTestCase::getDatabaseConnection
Returns the database connection to the site running Simpletest.
Return value
DatabaseConnection The database connection to use for inserting assertions.
File
-
modules/
simpletest/ drupal_web_test_case.php, line 213
Class
- DrupalTestCase
- Base class for Drupal tests.
Code
public static function getDatabaseConnection() {
try {
$connection = Database::getConnection('default', 'simpletest_original_default');
} catch (DatabaseConnectionNotDefinedException $e) {
// If the test was not set up, the simpletest_original_default
// connection does not exist.
$connection = Database::getConnection('default', 'default');
}
return $connection;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.