/**
* Returns the database connection to use for inserting assertions.
*
* @return \Drupal\Core\Database\Connection
* The database connection to use for inserting assertions.
*/
public static function getConnection(): Connection
{ // Check whether there is a test runner connection.
// @see run-tests.sh
// @todo Convert Simpletest UI runner to create + use this connection, too.
try { $connection = Database::
getConnection('default', 'test-runner'
);
} catch (ConnectionNotDefinedException
$e) { // Check whether there is a backup of the original default connection.
// @see FunctionalTestSetupTrait::prepareEnvironment()
try { $connection = Database::
getConnection('default', 'simpletest_original_default'
);
} catch (ConnectionNotDefinedException
$e) { // If FunctionalTestSetupTrait::prepareEnvironment() failed, the
// test-specific database connection does not exist yet/anymore, so
// fall back to the default of the (UI) test runner.