// that we can run the checkEngineVersion test.
Database::
getConnection();
// Revert to the old settings.
Database::
removeConnection('default'
);
Database::
addConnectionInfo('default', 'default',
$info['default'
]);
} else { // Rethrow the exception.
throw $e;
} } $this->
pass('Drupal can CONNECT to the database ok.'
);
} catch (\Exception
$e) { // Attempt to create the database if it is not found.
if ($e->
getCode() == Connection::DATABASE_NOT_FOUND
) { // Remove the database string from connection info.
$connection_info = Database::
getConnectionInfo();
$database =
$connection_info['default'
]['database'
];
unset($connection_info['default'
]['database'
]);
// In order to change the Database::$databaseInfo array, need to remove
// the active connection, then re-add it with the new info.