diff --git a/core/lib/Drupal/Core/Test/TestSetupTrait.php b/core/lib/Drupal/Core/Test/TestSetupTrait.php index 8bef66c3dc..44409078db 100644 --- a/core/lib/Drupal/Core/Test/TestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/TestSetupTrait.php @@ -159,8 +159,6 @@ protected function changeDatabasePrefix() { $db_url = getenv('SIMPLETEST_DB'); if (!empty($db_url)) { $database = Database::convertDbUrlToConnectionInfo($db_url, isset($this->root) ? $this->root : DRUPAL_ROOT); - // Ensure that the connection is added. - Database::removeConnection('default'); Database::addConnectionInfo('default', 'default', $database); } diff --git a/core/tests/Drupal/Setup/Commands/TestInstallationSetupCommand.php b/core/tests/Drupal/Setup/Commands/TestInstallationSetupCommand.php index 8e01727fcf..933c88ef3a 100644 --- a/core/tests/Drupal/Setup/Commands/TestInstallationSetupCommand.php +++ b/core/tests/Drupal/Setup/Commands/TestInstallationSetupCommand.php @@ -2,6 +2,7 @@ namespace Drupal\Setup\Commands; +use Drupal\Core\Database\Database; use Drupal\Core\Test\FunctionalTestSetupTrait; use Drupal\Core\Test\TestSetupTrait; use Drupal\Setup\TestSetupInterface; @@ -24,7 +25,9 @@ class TestInstallationSetupCommand extends Command { } use RandomGeneratorTrait; use SessionTestTrait; - use TestSetupTrait; + use TestSetupTrait { + changeDatabasePrefix as protected changeDatabasePrefixTrait; + } /** * The install profile to use. @@ -173,4 +176,13 @@ protected function installParameters() { return $parameters; } + /** + * {@inheritdoc} + */ + protected function changeDatabasePrefix() { + // Ensure that we use the database from SIMPLETEST_DB environment variable. + Database::removeConnection('default'); + $this->changeDatabasePrefixTrait(); + } + } diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php index 97ef81ea8a..adcf5b169a 100644 --- a/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -196,5 +196,5 @@ class_alias('\PHPUnit\Framework\MockObject\Matcher\InvokedRecorder', '\PHPUnit_F class_alias('\PHPUnit\Framework\SkippedTestError', '\PHPUnit_Framework_SkippedTestError'); class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); class_alias('\PHPUnit\Util\Test', '\PHPUnit_Util_Test'); - class_alias('\PHPUnit\Util\XML', '\PHPUnit_Util_XML'); + class_alias('\PHPUnit\Util\Xml', '\PHPUnit_Util_XML'); }