X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FTest%2FTestSetupTrait.php;h=0625691022cd451bde0804482f593089a792f654;hb=refs%2Fheads%2Fd864;hp=ea9137e479767669ed12c6f3ca0c56366e75a45b;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Test/TestSetupTrait.php b/web/core/lib/Drupal/Core/Test/TestSetupTrait.php index ea9137e47..062569102 100644 --- a/web/core/lib/Drupal/Core/Test/TestSetupTrait.php +++ b/web/core/lib/Drupal/Core/Test/TestSetupTrait.php @@ -141,7 +141,7 @@ trait TestSetupTrait { * @see \Drupal\simpletest\TestBase::prepareEnvironment() * @see drupal_valid_test_ua() */ - private function prepareDatabasePrefix() { + protected function prepareDatabasePrefix() { $test_db = new TestDatabase(); $this->siteDirectory = $test_db->getTestSitePath(); $this->databasePrefix = $test_db->getDatabasePrefix(); @@ -150,7 +150,7 @@ trait TestSetupTrait { /** * Changes the database connection to the prefixed one. */ - private function changeDatabasePrefix() { + protected function changeDatabasePrefix() { if (empty($this->databasePrefix)) { $this->prepareDatabasePrefix(); } @@ -158,7 +158,10 @@ trait TestSetupTrait { // If the test is run with argument dburl then use it. $db_url = getenv('SIMPLETEST_DB'); if (!empty($db_url)) { - $database = Database::convertDbUrlToConnectionInfo($db_url, DRUPAL_ROOT); + // Ensure no existing database gets in the way. If a default database + // exists already it must be removed. + Database::removeConnection('default'); + $database = Database::convertDbUrlToConnectionInfo($db_url, isset($this->root) ? $this->root : DRUPAL_ROOT); Database::addConnectionInfo('default', 'default', $database); }