protected function changeDatabasePrefix() { if (empty($this->databasePrefix
)) { $this->
prepareDatabasePrefix();
} // If the test is run with argument dburl then use it.
$db_url =
getenv('SIMPLETEST_DB'
);
if (!
empty($db_url)) { // 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,
$this->root ?? DRUPAL_ROOT, TRUE
);
Database::
addConnectionInfo('default', 'default',
$database);
} // Clone the current connection and replace the current prefix.
$connection_info = Database::
getConnectionInfo('default'
);
if (is_null($connection_info)) { throw new \
InvalidArgumentException('There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh.'
);
} else { Database::
renameConnection('default', 'simpletest_original_default'
);
foreach ($connection_info as $target =>
$value) {