diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 791bf7a..71420c0 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\Core\Database;
 
+use GuzzleHttp\Psr7\Uri;
+
 /**
  * Base Database API class.
  *
@@ -173,7 +175,9 @@ public function __construct(\PDO $connection, array $connection_options) {
    * @return \PDO
    *   A \PDO object.
    */
-  public static function open(array &$connection_options = array()) { }
+  public static function open(array &$connection_options = array()) {
+
+  }
 
   /**
    * Destroys this Connection object.
@@ -280,8 +284,7 @@ public function getConnectionOptions() {
   protected function setPrefix($prefix) {
     if (is_array($prefix)) {
       $this->prefixes = $prefix + array('default' => '');
-    }
-    else {
+    } else {
       $this->prefixes = array('default' => $prefix);
     }
 
@@ -339,8 +342,7 @@ public function prefixTables($sql) {
   public function tablePrefix($table = 'default') {
     if (isset($this->prefixes[$table])) {
       return $this->prefixes[$table];
-    }
-    else {
+    } else {
       return $this->prefixes['default'];
     }
   }
@@ -593,8 +595,7 @@ public function query($query, array $args = array(), $options = array()) {
       if ($query instanceof StatementInterface) {
         $stmt = $query;
         $stmt->execute(NULL, $options);
-      }
-      else {
+      } else {
         $this->expandArguments($query, $args);
         // To protect against SQL injection, Drupal only supports executing one
         // statement at a time.  Thus, the presence of a SQL delimiter (the
@@ -627,8 +628,7 @@ public function query($query, array $args = array(), $options = array()) {
         default:
           throw new \PDOException('Invalid return directive: ' . $options['return']);
       }
-    }
-    catch (\PDOException $e) {
+    } catch (\PDOException $e) {
       // Most database drivers will return NULL here, but some of them
       // (e.g. the SQLite driver) may need to re-run the query, so the return
       // value will be the same as for static::query().
@@ -666,8 +666,7 @@ protected function handleQueryException(\PDOException $e, $query, array $args =
       // Match all SQLSTATE 23xxx errors.
       if (substr($e->getCode(), -6, -3) == '23') {
         $exception = new IntegrityConstraintViolationException($message, $e->getCode(), $e);
-      }
-      else {
+      } else {
         $exception = new DatabaseExceptionWrapper($message, 0, $e);
       }
 
@@ -708,8 +707,7 @@ protected function expandArguments(&$query, &$args) {
       $is_array_data = is_array($data);
       if ($is_bracket_placeholder && !$is_array_data) {
         throw new \InvalidArgumentException('Placeholders with a trailing [] can only be expanded with an array of values.');
-      }
-      elseif (!$is_bracket_placeholder) {
+      } elseif (!$is_bracket_placeholder) {
         if ($is_array_data) {
           throw new \InvalidArgumentException('Placeholders must have a trailing [] if they are to be expanded with an array of values.');
         }
@@ -1090,8 +1088,7 @@ public function rollback($savepoint_name = 'drupal_transaction') {
           throw new TransactionOutOfOrderException();
         }
         return;
-      }
-      else {
+      } else {
         $rolled_back_other_active_savepoints = TRUE;
       }
     }
@@ -1124,8 +1121,7 @@ public function pushTransaction($name) {
     // rather than try to create another transaction.
     if ($this->inTransaction()) {
       $this->query('SAVEPOINT ' . $name);
-    }
-    else {
+    } else {
       $this->connection->beginTransaction();
     }
     $this->transactionLayers[$name] = $name;
@@ -1180,8 +1176,7 @@ protected function popCommittableTransactions() {
         if (!$this->connection->commit()) {
           throw new TransactionCommitFailedException();
         }
-      }
-      else {
+      } else {
         $this->query('RELEASE SAVEPOINT ' . $name);
       }
     }
@@ -1425,4 +1420,67 @@ public function __sleep() {
     throw new \LogicException('The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution.');
   }
 
+  /**
+   * A helper function to convert a URI into connection options.
+   *
+   * This method can be overridden in order to customise how a URI is converted.
+   *
+   * @internal
+   *   This method should not be called. Use
+   *   \Drupal\Core\Database\Database::convertDbUrlToConnectionInfo() instead.
+   *
+   * @param \GuzzleHttp\Psr7\Uri $uri
+   *   The URI to be converted to a connection array.
+   * @param string $root
+   *   The root directory of the Drupal installation.
+   * @param array $connection_options
+   *   The connection options.
+   *
+   * @return array
+   *   The connection options.
+   *
+   * @see \Drupal\Core\Database\Database::convertDbUrlToConnectionInfo()
+   */
+  public static function convertDbUrlToConnectionInfoHelper(Uri $uri, $root, array $connection_options) {
+    $port = $uri->getPort();
+    if (!empty($port)) {
+      $connection_options['port'] = $port;
+    }
+    $user_info = explode(':', $uri->getUserInfo(), 2);
+    $connection_options['username'] = $user_info[0];
+    $connection_options['password'] = isset($user_info[1]) ? $user_info[1] : '';
+
+    return $connection_options;
+  }
+
+  /**
+   * A helper function to convert connection options into a URI.
+   *
+   * This method can be overridden in order to customise how connection options
+   * are converted.
+   *
+   * @internal
+   *   This method should not be called. Use
+   *   \Drupal\Core\Database\Database::getConnectionInfoAsUrl() instead.
+   *
+   * @param array $connection_options
+   *   The array of connection options for a database connection.
+   * @param \GuzzleHttp\Psr7\Uri $uri
+   *   The URI to connect to the database.
+   *
+   * @return $this|\GuzzleHttp\Psr7\Uri
+   *   The URI to connect to the database.
+   *
+   * @see \Drupal\Core\Database\Database::getConnectionInfoAsUrl()
+   */
+  public static function getConnectionInfoAsUrlHelper(array $connection_options, Uri $uri) {
+    $user = isset($connection_options['username']) ? $connection_options['username'] : '';
+    $password = isset($connection_options['password']) ? $connection_options['password'] : '';
+    $uri = $uri->withUserInfo($user, $password);
+    if (!empty($connection_options['port'])) {
+      $uri = $uri->withPort($connection_options['port']);
+    }
+    return $uri;
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index e1a5c2a..a7ea3fd 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\Core\Database;
 
+use GuzzleHttp\Psr7\Uri;
+
 /**
  * Primary front-controller for the database system.
  *
@@ -11,516 +13,525 @@
  */
 abstract class Database {
 
-  /**
-   * Flag to indicate a query call should simply return NULL.
-   *
-   * This is used for queries that have no reasonable return value anyway, such
-   * as INSERT statements to a table without a serial primary key.
-   */
-  const RETURN_NULL = 0;
-
-  /**
-   * Flag to indicate a query call should return the prepared statement.
-   */
-  const RETURN_STATEMENT = 1;
-
-  /**
-   * Flag to indicate a query call should return the number of affected rows.
-   */
-  const RETURN_AFFECTED = 2;
-
-  /**
-   * Flag to indicate a query call should return the "last insert id".
-   */
-  const RETURN_INSERT_ID = 3;
-
-  /**
-   * An nested array of all active connections. It is keyed by database name
-   * and target.
-   *
-   * @var array
-   */
-  static protected $connections = array();
-
-  /**
-   * A processed copy of the database connection information from settings.php.
-   *
-   * @var array
-   */
-  static protected $databaseInfo = array();
-
-  /**
-   * A list of key/target credentials to simply ignore.
-   *
-   * @var array
-   */
-  static protected $ignoreTargets = array();
-
-  /**
-   * The key of the currently active database connection.
-   *
-   * @var string
-   */
-  static protected $activeKey = 'default';
-
-  /**
-   * An array of active query log objects.
-   *
-   * Every connection has one and only one logger object for all targets and
-   * logging keys.
-   *
-   * array(
-   *   '$db_key' => DatabaseLog object.
-   * );
-   *
-   * @var array
-   */
-  static protected $logs = array();
-
-  /**
-   * Starts logging a given logging key on the specified connection.
-   *
-   * @param string $logging_key
-   *   The logging key to log.
-   * @param string $key
-   *   The database connection key for which we want to log.
-   *
-   * @return \Drupal\Core\Database\Log
-   *   The query log object. Note that the log object does support richer
-   *   methods than the few exposed through the Database class, so in some
-   *   cases it may be desirable to access it directly.
-   *
-   * @see \Drupal\Core\Database\Log
-   */
-  final public static function startLog($logging_key, $key = 'default') {
-    if (empty(self::$logs[$key])) {
-      self::$logs[$key] = new Log($key);
-
-      // Every target already active for this connection key needs to have the
-      // logging object associated with it.
-      if (!empty(self::$connections[$key])) {
-        foreach (self::$connections[$key] as $connection) {
-          $connection->setLogger(self::$logs[$key]);
-        }
-      }
-    }
-
-    self::$logs[$key]->start($logging_key);
-    return self::$logs[$key];
-  }
-
-  /**
-   * Retrieves the queries logged on for given logging key.
-   *
-   * This method also ends logging for the specified key. To get the query log
-   * to date without ending the logger request the logging object by starting
-   * it again (which does nothing to an open log key) and call methods on it as
-   * desired.
-   *
-   * @param string $logging_key
-   *   The logging key to log.
-   * @param string $key
-   *   The database connection key for which we want to log.
-   *
-   * @return array
-   *   The query log for the specified logging key and connection.
-   *
-   * @see \Drupal\Core\Database\Log
-   */
-  final public static function getLog($logging_key, $key = 'default') {
-    if (empty(self::$logs[$key])) {
-      return NULL;
-    }
-    $queries = self::$logs[$key]->get($logging_key);
-    self::$logs[$key]->end($logging_key);
-    return $queries;
-  }
-
-  /**
-   * Gets the connection object for the specified database key and target.
-   *
-   * @param string $target
-   *   The database target name.
-   * @param string $key
-   *   The database connection key. Defaults to NULL which means the active key.
-   *
-   * @return \Drupal\Core\Database\Connection
-   *   The corresponding connection object.
-   */
-  final public static function getConnection($target = 'default', $key = NULL) {
-    if (!isset($key)) {
-      // By default, we want the active connection, set in setActiveConnection.
-      $key = self::$activeKey;
-    }
-    // If the requested target does not exist, or if it is ignored, we fall back
-    // to the default target. The target is typically either "default" or
-    // "replica", indicating to use a replica SQL server if one is available. If
-    // it's not available, then the default/primary server is the correct server
-    // to use.
-    if (!empty(self::$ignoreTargets[$key][$target]) || !isset(self::$databaseInfo[$key][$target])) {
-      $target = 'default';
-    }
-
-    if (!isset(self::$connections[$key][$target])) {
-      // If necessary, a new connection is opened.
-      self::$connections[$key][$target] = self::openConnection($key, $target);
-    }
-    return self::$connections[$key][$target];
-  }
-
-  /**
-   * Determines if there is an active connection.
-   *
-   * Note that this method will return FALSE if no connection has been
-   * established yet, even if one could be.
-   *
-   * @return bool
-   *   TRUE if there is at least one database connection established, FALSE
-   *   otherwise.
-   */
-  final public static function isActiveConnection() {
-    return !empty(self::$activeKey) && !empty(self::$connections) && !empty(self::$connections[self::$activeKey]);
-  }
-
-  /**
-   * Sets the active connection to the specified key.
-   *
-   * @return string|null
-   *   The previous database connection key.
-   */
-  final public static function setActiveConnection($key = 'default') {
-    if (!empty(self::$databaseInfo[$key])) {
-      $old_key = self::$activeKey;
-      self::$activeKey = $key;
-      return $old_key;
-    }
-  }
-
-  /**
-   * Process the configuration file for database information.
-   *
-   * @param array $info
-   *   The database connection information, as defined in settings.php. The
-   *   structure of this array depends on the database driver it is connecting
-   *   to.
-   */
-  final public static function parseConnectionInfo(array $info) {
-    // If there is no "driver" property, then we assume it's an array of
-    // possible connections for this target. Pick one at random. That allows
-    // us to have, for example, multiple replica servers.
-    if (empty($info['driver'])) {
-      $info = $info[mt_rand(0, count($info) - 1)];
-    }
-    // Parse the prefix information.
-    if (!isset($info['prefix'])) {
-      // Default to an empty prefix.
-      $info['prefix'] = array(
-        'default' => '',
-      );
-    }
-    elseif (!is_array($info['prefix'])) {
-      // Transform the flat form into an array form.
-      $info['prefix'] = array(
-        'default' => $info['prefix'],
-      );
-    }
-    return $info;
-  }
-
-  /**
-   * Adds database connection information for a given key/target.
-   *
-   * This method allows to add new connections at runtime.
-   *
-   * Under normal circumstances the preferred way to specify database
-   * credentials is via settings.php. However, this method allows them to be
-   * added at arbitrary times, such as during unit tests, when connecting to
-   * admin-defined third party databases, etc.
-   *
-   * If the given key/target pair already exists, this method will be ignored.
-   *
-   * @param string $key
-   *   The database key.
-   * @param string $target
-   *   The database target name.
-   * @param array $info
-   *   The database connection information, as defined in settings.php. The
-   *   structure of this array depends on the database driver it is connecting
-   *   to.
-   */
-  final public static function addConnectionInfo($key, $target, array $info) {
-    if (empty(self::$databaseInfo[$key][$target])) {
-      self::$databaseInfo[$key][$target] = self::parseConnectionInfo($info);
-    }
-  }
-
-  /**
-   * Gets information on the specified database connection.
-   *
-   * @param string $key
-   *   (optional) The connection key for which to return information.
-   *
-   * @return array|null
-   */
-  final public static function getConnectionInfo($key = 'default') {
-    if (!empty(self::$databaseInfo[$key])) {
-      return self::$databaseInfo[$key];
-    }
-  }
-
-  /**
-   * Gets connection information for all available databases.
-   *
-   * @return array
-   */
-  final public static function getAllConnectionInfo() {
-    return self::$databaseInfo;
-  }
-
-  /**
-   * Sets connection information for multiple databases.
-   *
-   * @param array $databases
-   *   A multi-dimensional array specifying database connection parameters, as
-   *   defined in settings.php.
-   */
-  final public static function setMultipleConnectionInfo(array $databases) {
-    foreach ($databases as $key => $targets) {
-      foreach ($targets as $target => $info) {
-        self::addConnectionInfo($key, $target, $info);
-      }
-    }
-  }
-
-  /**
-   * Rename a connection and its corresponding connection information.
-   *
-   * @param string $old_key
-   *   The old connection key.
-   * @param string $new_key
-   *   The new connection key.
-   *
-   * @return bool
-   *   TRUE in case of success, FALSE otherwise.
-   */
-  final public static function renameConnection($old_key, $new_key) {
-    if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) {
-      // Migrate the database connection information.
-      self::$databaseInfo[$new_key] = self::$databaseInfo[$old_key];
-      unset(self::$databaseInfo[$old_key]);
-
-      // Migrate over the DatabaseConnection object if it exists.
-      if (isset(self::$connections[$old_key])) {
-        self::$connections[$new_key] = self::$connections[$old_key];
-        unset(self::$connections[$old_key]);
-      }
-
-      return TRUE;
-    }
-    else {
-      return FALSE;
-    }
-  }
-
-  /**
-   * Remove a connection and its corresponding connection information.
-   *
-   * @param string $key
-   *   The connection key.
-   *
-   * @return bool
-   *   TRUE in case of success, FALSE otherwise.
-   */
-  final public static function removeConnection($key) {
-    if (isset(self::$databaseInfo[$key])) {
-      self::closeConnection(NULL, $key);
-      unset(self::$databaseInfo[$key]);
-      return TRUE;
-    }
-    else {
-      return FALSE;
-    }
-  }
-
-  /**
-   * Opens a connection to the server specified by the given key and target.
-   *
-   * @param string $key
-   *   The database connection key, as specified in settings.php. The default is
-   *   "default".
-   * @param string $target
-   *   The database target to open.
-   *
-   * @throws \Drupal\Core\Database\ConnectionNotDefinedException
-   * @throws \Drupal\Core\Database\DriverNotSpecifiedException
-   */
-  final protected static function openConnection($key, $target) {
-    // If the requested database does not exist then it is an unrecoverable
-    // error.
-    if (!isset(self::$databaseInfo[$key])) {
-      throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
-    }
-
-    if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
-      throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
-    }
-
-    if (!empty(self::$databaseInfo[$key][$target]['namespace'])) {
-      $driver_class = self::$databaseInfo[$key][$target]['namespace'] . '\\Connection';
-    }
-    else {
-      // Fallback for Drupal 7 settings.php.
-      $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Connection";
-    }
-
-    $pdo_connection = $driver_class::open(self::$databaseInfo[$key][$target]);
-    $new_connection = new $driver_class($pdo_connection, self::$databaseInfo[$key][$target]);
-    $new_connection->setTarget($target);
-    $new_connection->setKey($key);
-
-    // If we have any active logging objects for this connection key, we need
-    // to associate them with the connection we just opened.
-    if (!empty(self::$logs[$key])) {
-      $new_connection->setLogger(self::$logs[$key]);
-    }
-
-    return $new_connection;
-  }
-
-  /**
-   * Closes a connection to the server specified by the given key and target.
-   *
-   * @param string $target
-   *   The database target name.  Defaults to NULL meaning that all target
-   *   connections will be closed.
-   * @param string $key
-   *   The database connection key. Defaults to NULL which means the active key.
-   */
-  public static function closeConnection($target = NULL, $key = NULL) {
-    // Gets the active connection by default.
-    if (!isset($key)) {
-      $key = self::$activeKey;
-    }
-    // To close a connection, it needs to be set to NULL and removed from the
-    // static variable. In all cases, closeConnection() might be called for a
-    // connection that was not opened yet, in which case the key is not defined
-    // yet and we just ensure that the connection key is undefined.
-    if (isset($target)) {
-      if (isset(self::$connections[$key][$target])) {
-        self::$connections[$key][$target]->destroy();
-        self::$connections[$key][$target] = NULL;
-      }
-      unset(self::$connections[$key][$target]);
-    }
-    else {
-      if (isset(self::$connections[$key])) {
-        foreach (self::$connections[$key] as $target => $connection) {
-          self::$connections[$key][$target]->destroy();
-          self::$connections[$key][$target] = NULL;
-        }
-      }
-      unset(self::$connections[$key]);
-    }
-  }
-
-  /**
-   * Instructs the system to temporarily ignore a given key/target.
-   *
-   * At times we need to temporarily disable replica queries. To do so, call this
-   * method with the database key and the target to disable. That database key
-   * will then always fall back to 'default' for that key, even if it's defined.
-   *
-   * @param string $key
-   *   The database connection key.
-   * @param string $target
-   *   The target of the specified key to ignore.
-   */
-  public static function ignoreTarget($key, $target) {
-    self::$ignoreTargets[$key][$target] = TRUE;
-  }
-
-  /**
-   * Converts a URL to a database connection info array.
-   *
-   * @param string $url
-   *   The URL.
-   * @param string $root
-   *   The root directory of the Drupal installation.
-   *
-   * @return array
-   *   The database connection info.
-   *
-   * @throws \InvalidArgumentException
-   *   Exception thrown when the provided URL does not meet the minimum
-   *   requirements.
-   */
-  public static function convertDbUrlToConnectionInfo($url, $root) {
-    $info = parse_url($url);
-    if (!isset($info['scheme'], $info['host'], $info['path'])) {
-      throw new \InvalidArgumentException('Minimum requirement: driver://host/database');
-    }
-    $info += array(
-      'user' => '',
-      'pass' => '',
-      'fragment' => '',
-    );
-
-    // A SQLite database path with two leading slashes indicates a system path.
-    // Otherwise the path is relative to the Drupal root.
-    if ($info['path'][0] === '/') {
-      $info['path'] = substr($info['path'], 1);
-    }
-    if ($info['scheme'] === 'sqlite' && $info['path'][0] !== '/') {
-      $info['path'] = $root . '/' . $info['path'];
-    }
-
-    $database = array(
-      'driver' => $info['scheme'],
-      'username' => $info['user'],
-      'password' => $info['pass'],
-      'host' => $info['host'],
-      'database' => $info['path'],
-    );
-    if (isset($info['port'])) {
-      $database['port'] = $info['port'];
-    }
-    return $database;
-  }
-
-  /**
-   * Gets database connection info as a URL.
-   *
-   * @param string $key
-   *   (Optional) The database connection key.
-   *
-   * @return string
-   *   The connection info as a URL.
-   */
-  public static function getConnectionInfoAsUrl($key = 'default') {
-    $db_info = static::getConnectionInfo($key);
-    if ($db_info['default']['driver'] == 'sqlite') {
-      $db_url = 'sqlite://localhost/' . $db_info['default']['database'];
-    }
-    else {
-      $user = '';
-      if ($db_info['default']['username']) {
-        $user = $db_info['default']['username'];
-        if ($db_info['default']['password']) {
-          $user .= ':' . $db_info['default']['password'];
-        }
-        $user .= '@';
-      }
-
-      $db_url = $db_info['default']['driver'] . '://' . $user . $db_info['default']['host'];
-      if (isset($db_info['default']['port'])) {
-        $db_url .= ':' . $db_info['default']['port'];
-      }
-      $db_url .= '/' . $db_info['default']['database'];
-    }
-    if ($db_info['default']['prefix']['default']) {
-      $db_url .= '#' . $db_info['default']['prefix']['default'];
-    }
-    return $db_url;
-  }
+	/**
+	 * Flag to indicate a query call should simply return NULL.
+	 *
+	 * This is used for queries that have no reasonable return value anyway, such
+	 * as INSERT statements to a table without a serial primary key.
+	 */
+	const RETURN_NULL = 0;
+
+	/**
+	 * Flag to indicate a query call should return the prepared statement.
+	 */
+	const RETURN_STATEMENT = 1;
+
+	/**
+	 * Flag to indicate a query call should return the number of affected rows.
+	 */
+	const RETURN_AFFECTED = 2;
+
+	/**
+	 * Flag to indicate a query call should return the "last insert id".
+	 */
+	const RETURN_INSERT_ID = 3;
+
+	/**
+	 * An nested array of all active connections. It is keyed by database name
+	 * and target.
+	 *
+	 * @var array
+	 */
+	static protected $connections = array();
+
+	/**
+	 * A processed copy of the database connection information from settings.php.
+	 *
+	 * @var array
+	 */
+	static protected $databaseInfo = array();
+
+	/**
+	 * A list of key/target credentials to simply ignore.
+	 *
+	 * @var array
+	 */
+	static protected $ignoreTargets = array();
+
+	/**
+	 * The key of the currently active database connection.
+	 *
+	 * @var string
+	 */
+	static protected $activeKey = 'default';
+
+	/**
+	 * An array of active query log objects.
+	 *
+	 * Every connection has one and only one logger object for all targets and
+	 * logging keys.
+	 *
+	 * array(
+	 *   '$db_key' => DatabaseLog object.
+	 * );
+	 *
+	 * @var array
+	 */
+	static protected $logs = array();
+
+	/**
+	 * Starts logging a given logging key on the specified connection.
+	 *
+	 * @param string $logging_key
+	 *   The logging key to log.
+	 * @param string $key
+	 *   The database connection key for which we want to log.
+	 *
+	 * @return \Drupal\Core\Database\Log
+	 *   The query log object. Note that the log object does support richer
+	 *   methods than the few exposed through the Database class, so in some
+	 *   cases it may be desirable to access it directly.
+	 *
+	 * @see \Drupal\Core\Database\Log
+	 */
+	final public static function startLog($logging_key, $key = 'default') {
+		if (empty(self::$logs[$key])) {
+			self::$logs[$key] = new Log($key);
+
+			// Every target already active for this connection key needs to have the
+			// logging object associated with it.
+			if (!empty(self::$connections[$key])) {
+				foreach (self::$connections[$key] as $connection) {
+					$connection->setLogger(self::$logs[$key]);
+				}
+			}
+		}
+
+		self::$logs[$key]->start($logging_key);
+		return self::$logs[$key];
+	}
+
+	/**
+	 * Retrieves the queries logged on for given logging key.
+	 *
+	 * This method also ends logging for the specified key. To get the query log
+	 * to date without ending the logger request the logging object by starting
+	 * it again (which does nothing to an open log key) and call methods on it as
+	 * desired.
+	 *
+	 * @param string $logging_key
+	 *   The logging key to log.
+	 * @param string $key
+	 *   The database connection key for which we want to log.
+	 *
+	 * @return array
+	 *   The query log for the specified logging key and connection.
+	 *
+	 * @see \Drupal\Core\Database\Log
+	 */
+	final public static function getLog($logging_key, $key = 'default') {
+		if (empty(self::$logs[$key])) {
+			return NULL;
+		}
+		$queries = self::$logs[$key]->get($logging_key);
+		self::$logs[$key]->end($logging_key);
+		return $queries;
+	}
+
+	/**
+	 * Gets the connection object for the specified database key and target.
+	 *
+	 * @param string $target
+	 *   The database target name.
+	 * @param string $key
+	 *   The database connection key. Defaults to NULL which means the active key.
+	 *
+	 * @return \Drupal\Core\Database\Connection
+	 *   The corresponding connection object.
+	 */
+	final public static function getConnection($target = 'default', $key = NULL) {
+		if (!isset($key)) {
+			// By default, we want the active connection, set in setActiveConnection.
+			$key = self::$activeKey;
+		}
+		// If the requested target does not exist, or if it is ignored, we fall back
+		// to the default target. The target is typically either "default" or
+		// "replica", indicating to use a replica SQL server if one is available. If
+		// it's not available, then the default/primary server is the correct server
+		// to use.
+		if (!empty(self::$ignoreTargets[$key][$target]) || !isset(self::$databaseInfo[$key][$target])) {
+			$target = 'default';
+		}
+
+		if (!isset(self::$connections[$key][$target])) {
+			// If necessary, a new connection is opened.
+			self::$connections[$key][$target] = self::openConnection($key, $target);
+		}
+		return self::$connections[$key][$target];
+	}
+
+	/**
+	 * Determines if there is an active connection.
+	 *
+	 * Note that this method will return FALSE if no connection has been
+	 * established yet, even if one could be.
+	 *
+	 * @return bool
+	 *   TRUE if there is at least one database connection established, FALSE
+	 *   otherwise.
+	 */
+	final public static function isActiveConnection() {
+		return !empty(self::$activeKey) && !empty(self::$connections) && !empty(self::$connections[self::$activeKey]);
+	}
+
+	/**
+	 * Sets the active connection to the specified key.
+	 *
+	 * @return string|null
+	 *   The previous database connection key.
+	 */
+	final public static function setActiveConnection($key = 'default') {
+		if (!empty(self::$databaseInfo[$key])) {
+			$old_key = self::$activeKey;
+			self::$activeKey = $key;
+			return $old_key;
+		}
+	}
+
+	/**
+	 * Process the configuration file for database information.
+	 *
+	 * @param array $info
+	 *   The database connection information, as defined in settings.php. The
+	 *   structure of this array depends on the database driver it is connecting
+	 *   to.
+	 */
+	final public static function parseConnectionInfo(array $info) {
+		// If there is no "driver" property, then we assume it's an array of
+		// possible connections for this target. Pick one at random. That allows
+		// us to have, for example, multiple replica servers.
+		if (empty($info['driver'])) {
+			$info = $info[mt_rand(0, count($info) - 1)];
+		}
+		// Parse the prefix information.
+		if (!isset($info['prefix'])) {
+			// Default to an empty prefix.
+			$info['prefix'] = array(
+				'default' => '',
+			);
+		} elseif (!is_array($info['prefix'])) {
+			// Transform the flat form into an array form.
+			$info['prefix'] = array(
+				'default' => $info['prefix'],
+			);
+		}
+		return $info;
+	}
+
+	/**
+	 * Adds database connection information for a given key/target.
+	 *
+	 * This method allows to add new connections at runtime.
+	 *
+	 * Under normal circumstances the preferred way to specify database
+	 * credentials is via settings.php. However, this method allows them to be
+	 * added at arbitrary times, such as during unit tests, when connecting to
+	 * admin-defined third party databases, etc.
+	 *
+	 * If the given key/target pair already exists, this method will be ignored.
+	 *
+	 * @param string $key
+	 *   The database key.
+	 * @param string $target
+	 *   The database target name.
+	 * @param array $info
+	 *   The database connection information, as defined in settings.php. The
+	 *   structure of this array depends on the database driver it is connecting
+	 *   to.
+	 */
+	final public static function addConnectionInfo($key, $target, array $info) {
+		if (empty(self::$databaseInfo[$key][$target])) {
+			self::$databaseInfo[$key][$target] = self::parseConnectionInfo($info);
+		}
+	}
+
+	/**
+	 * Gets information on the specified database connection.
+	 *
+	 * @param string $key
+	 *   (optional) The connection key for which to return information.
+	 *
+	 * @return array|null
+	 */
+	final public static function getConnectionInfo($key = 'default') {
+		if (!empty(self::$databaseInfo[$key])) {
+			return self::$databaseInfo[$key];
+		}
+	}
+
+	/**
+	 * Gets connection information for all available databases.
+	 *
+	 * @return array
+	 */
+	final public static function getAllConnectionInfo() {
+		return self::$databaseInfo;
+	}
+
+	/**
+	 * Sets connection information for multiple databases.
+	 *
+	 * @param array $databases
+	 *   A multi-dimensional array specifying database connection parameters, as
+	 *   defined in settings.php.
+	 */
+	final public static function setMultipleConnectionInfo(array $databases) {
+		foreach ($databases as $key => $targets) {
+			foreach ($targets as $target => $info) {
+				self::addConnectionInfo($key, $target, $info);
+			}
+		}
+	}
+
+	/**
+	 * Rename a connection and its corresponding connection information.
+	 *
+	 * @param string $old_key
+	 *   The old connection key.
+	 * @param string $new_key
+	 *   The new connection key.
+	 *
+	 * @return bool
+	 *   TRUE in case of success, FALSE otherwise.
+	 */
+	final public static function renameConnection($old_key, $new_key) {
+		if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) {
+			// Migrate the database connection information.
+			self::$databaseInfo[$new_key] = self::$databaseInfo[$old_key];
+			unset(self::$databaseInfo[$old_key]);
+
+			// Migrate over the DatabaseConnection object if it exists.
+			if (isset(self::$connections[$old_key])) {
+				self::$connections[$new_key] = self::$connections[$old_key];
+				unset(self::$connections[$old_key]);
+			}
+
+			return TRUE;
+		} else {
+			return FALSE;
+		}
+	}
+
+	/**
+	 * Remove a connection and its corresponding connection information.
+	 *
+	 * @param string $key
+	 *   The connection key.
+	 *
+	 * @return bool
+	 *   TRUE in case of success, FALSE otherwise.
+	 */
+	final public static function removeConnection($key) {
+		if (isset(self::$databaseInfo[$key])) {
+			self::closeConnection(NULL, $key);
+			unset(self::$databaseInfo[$key]);
+			return TRUE;
+		} else {
+			return FALSE;
+		}
+	}
+
+	/**
+	 * Opens a connection to the server specified by the given key and target.
+	 *
+	 * @param string $key
+	 *   The database connection key, as specified in settings.php. The default is
+	 *   "default".
+	 * @param string $target
+	 *   The database target to open.
+	 *
+	 * @throws \Drupal\Core\Database\ConnectionNotDefinedException
+	 * @throws \Drupal\Core\Database\DriverNotSpecifiedException
+	 */
+	final protected static function openConnection($key, $target) {
+		// If the requested database does not exist then it is an unrecoverable
+		// error.
+		if (!isset(self::$databaseInfo[$key])) {
+			throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
+		}
+
+		if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
+			throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
+		}
+
+		$namespace = !empty(self::$databaseInfo[$key][$target]['namespace']) ? self::$databaseInfo[$key][$target]['namespace'] : NULL;
+		$driver_class = static::getDatabaseConnectionClass($driver, $namespace);
+
+		$pdo_connection = $driver_class::open(self::$databaseInfo[$key][$target]);
+		$new_connection = new $driver_class($pdo_connection, self::$databaseInfo[$key][$target]);
+		$new_connection->setTarget($target);
+		$new_connection->setKey($key);
+
+		// If we have any active logging objects for this connection key, we need
+		// to associate them with the connection we just opened.
+		if (!empty(self::$logs[$key])) {
+			$new_connection->setLogger(self::$logs[$key]);
+		}
+
+		return $new_connection;
+	}
+
+	/**
+	 * Closes a connection to the server specified by the given key and target.
+	 *
+	 * @param string $target
+	 *   The database target name.  Defaults to NULL meaning that all target
+	 *   connections will be closed.
+	 * @param string $key
+	 *   The database connection key. Defaults to NULL which means the active key.
+	 */
+	public static function closeConnection($target = NULL, $key = NULL) {
+		// Gets the active connection by default.
+		if (!isset($key)) {
+			$key = self::$activeKey;
+		}
+		// To close a connection, it needs to be set to NULL and removed from the
+		// static variable. In all cases, closeConnection() might be called for a
+		// connection that was not opened yet, in which case the key is not defined
+		// yet and we just ensure that the connection key is undefined.
+		if (isset($target)) {
+			if (isset(self::$connections[$key][$target])) {
+				self::$connections[$key][$target]->destroy();
+				self::$connections[$key][$target] = NULL;
+			}
+			unset(self::$connections[$key][$target]);
+		} else {
+			if (isset(self::$connections[$key])) {
+				foreach (self::$connections[$key] as $target => $connection) {
+					self::$connections[$key][$target]->destroy();
+					self::$connections[$key][$target] = NULL;
+				}
+			}
+			unset(self::$connections[$key]);
+		}
+	}
+
+	/**
+	 * Instructs the system to temporarily ignore a given key/target.
+	 *
+	 * At times we need to temporarily disable replica queries. To do so, call this
+	 * method with the database key and the target to disable. That database key
+	 * will then always fall back to 'default' for that key, even if it's defined.
+	 *
+	 * @param string $key
+	 *   The database connection key.
+	 * @param string $target
+	 *   The target of the specified key to ignore.
+	 */
+	public static function ignoreTarget($key, $target) {
+		self::$ignoreTargets[$key][$target] = TRUE;
+	}
+
+	/**
+	 * Converts a URL to a database connection info array.
+	 *
+	 * @param string $url
+	 *   The URL.
+	 * @param string $root
+	 *   The root directory of the Drupal installation.
+	 *
+	 * @return array
+	 *   The database connection info.
+	 *
+	 * @throws \InvalidArgumentException
+	 *   Exception thrown when the provided URL does not meet the minimum
+	 *   requirements.
+	 */
+	public static function convertDbUrlToConnectionInfo($url, $root) {
+		$uri = new Uri($url);
+		if (empty($uri->getHost()) || empty($uri->getSchema()) || empty($uri->getPath())) {
+			throw new \InvalidArgumentException('Minimum requirement: driver://host/database');
+		}
+
+		// Discover if the URL has a driver namespace.
+		$parts = array();
+		parse_str($uri->getQuery(), $parts);
+		$namespace = isset($parts['namespace']) ? $parts['namespace'] : '';
+
+		$fragment = $uri->getFragment();
+		$connection_opptions = array(
+			'driver' => $uri->getScheme(),
+			'host' => $uri->getHost(),
+			// Strip the first leading slash of the path to get the database name.
+			// Note that additional leading slashes have meaning for some database
+			// drivers.
+			'database' => substr($uri->getPath(), 1),
+			'prefix' => $fragment ? : NULL,
+			'namespace' => $namespace,
+		);
+
+		$driver_class = static::getDatabaseConnectionClass($connection_opptions['driver'], $connection_opptions['namespace']);
+		if (!class_exists($driver_class)) {
+			throw new \RuntimeException("Can not convert $url to a database connection, class $driver_class does not exist");
+		}
+		return $driver_class::convertDbUrlToConnectionInfoHelper($uri, $root, $connection_opptions);
+	}
+
+	/**
+	 * Gets database connection info as a URL.
+	 *
+	 * @param string $key
+	 *   (Optional) The database connection key.
+	 *
+	 * @return string
+	 *   The connection info as a URL.
+	 */
+	public static function getConnectionInfoAsUrl($key = 'default') {
+		$db_info = static::getConnectionInfo($key);
+		if (empty($db_info)) {
+			throw new \RuntimeException("Database connection $key not defined");
+		}
+
+		$namespace = isset($db_info['default']['namespace']) ? $db_info['default']['namespace'] : NULL;
+		$driver_class = static::getDatabaseConnectionClass($db_info['default']['driver'], $namespace);
+
+		// Some database driver do not need a host setting to work but in order to
+		// be converted into a URL they do.
+		$host = isset($db_info['default']['host']) ? $db_info['default']['host'] : 'localhost';
+
+		// Create a URI with the minimum requirement of driver://host/database.
+		$uri = new Uri($db_info['default']['driver'] . '://' . $host . '/' . $db_info['default']['database']);
+
+		if (!empty($db_info['default']['prefix']['default'])) {
+			$uri = $uri->withFragment($db_info['default']['prefix']['default']);
+		}
+		if (!empty($db_info['default']['namespace'])) {
+			$uri = Uri::withQueryValue($uri, 'namespace', $db_info['default']['namespace']);
+		}
+
+		$uri = $driver_class::getConnectionInfoAsUrlHelper($db_info['default'], $uri);
+		return (string) $uri;
+	}
+
+	/**
+	 * Gets the fully qualified connection class name for a database driver.
+	 *
+	 * @param string $driver
+	 *   The database driver to get the class for.
+	 * @param string $namespace
+	 *   A custom namespace to use.
+	 *
+	 * @return string
+	 *   The fully qualified class name of the driver's database connection class.
+	 */
+	public static function getDatabaseConnectionClass($driver, $namespace) {
+		if ($namespace) {
+			$driver_class = $namespace . '\\Connection';
+		} else {
+			// Fallback for Drupal 7 settings.php.
+			$driver_class = 'Drupal\\Core\\Database\\Driver\\' . $driver . '\\Connection';
+		}
+		return $driver_class;
+	}
 
 }
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
index 2f5374b..bf13d5e 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
@@ -5,6 +5,7 @@
 use Drupal\Core\Database\Database;
 use Drupal\Core\Database\DatabaseNotFoundException;
 use Drupal\Core\Database\Connection as DatabaseConnection;
+use GuzzleHttp\Psr7\Uri;
 
 /**
  * SQLite implementation of \Drupal\Core\Database\Connection.
@@ -410,4 +411,30 @@ public function getFullQualifiedTableName($table) {
     return $prefix . $table;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function convertDbUrlToConnectionInfoHelper(Uri $uri, $root, array $database) {
+    // A SQLite database with a leading slash indicates a system path.
+    // Otherwise the path is relative to the Drupal root.
+    if ($database['database'][0] !== '/') {
+      $database['database'] = $root . '/' . $database['database'];
+    }
+    // The host setting is meaningless for SQLite databases.
+    unset($database['host']);
+    return $database;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getConnectionInfoAsUrlHelper(array $connection_options, Uri $uri) {
+    if ($connection_options['database'][0] === '/') {
+      // If the database is a absolute path add an additional leading slash to
+      // denote this.
+      $uri = $uri->withPath('/' . $connection_options['database']);
+    }
+    return $uri;
+  }
+
 }
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 751a729..0686fe1 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -304,10 +304,12 @@ function simpletest_phpunit_configuration_filepath() {
  *   The results as returned by exec().
  */
 function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpunit_file, &$status = NULL) {
-  global $base_url;
-  // Setup an environment variable containing the database connection so that
-  // functional tests can connect to the database.
-  putenv('SIMPLETEST_DB=' . Database::getConnectionInfoAsUrl());
+	global $base_url;
+  if (Database::getConnectionInfo()) {
+    // Setup an environment variable containing the database connection so that
+    // functional tests can connect to the database.
+    putenv('SIMPLETEST_DB=' . Database::getConnectionInfoAsUrl());
+  }
 
   // Setup an environment variable containing the base URL, if it is available.
   // This allows functional tests to browse the site under test. When running
diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
index 8f4aa7a..af23427 100644
--- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\Core\Database;
 
-use Drupal\Tests\Core\Database\Stub\StubConnection;
+use Drupal\Tests\Core\Database\Stub\Connection;
 use Drupal\Tests\UnitTestCase;
 
 /**
@@ -46,10 +46,10 @@ public function providerPrefixRoundTrip() {
    */
   public function testPrefixRoundTrip($expected, $prefix_info) {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    $connection = new StubConnection($mock_pdo, array());
+    $connection = new Connection($mock_pdo, array());
 
     // setPrefix() is protected, so we make it accessible with reflection.
-    $reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\StubConnection');
+    $reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\Connection');
     $set_prefix = $reflection->getMethod('setPrefix');
     $set_prefix->setAccessible(TRUE);
 
@@ -95,7 +95,7 @@ public function providerTestPrefixTables() {
    */
   public function testPrefixTables($expected, $prefix_info, $query) {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    $connection = new StubConnection($mock_pdo, array('prefix' => $prefix_info));
+    $connection = new Connection($mock_pdo, array('prefix' => $prefix_info));
     $this->assertEquals($expected, $connection->prefixTables($query));
   }
 
@@ -129,7 +129,7 @@ public function providerEscapeMethods() {
    */
   public function testEscapeMethods($expected, $name) {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    $connection = new StubConnection($mock_pdo, array());
+    $connection = new Connection($mock_pdo, array());
     $this->assertEquals($expected, $connection->escapeDatabase($name));
     $this->assertEquals($expected, $connection->escapeTable($name));
     $this->assertEquals($expected, $connection->escapeField($name));
@@ -173,7 +173,7 @@ public function providerGetDriverClass() {
    */
   public function testGetDriverClass($expected, $namespace, $class) {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    $connection = new StubConnection($mock_pdo, array('namespace' => $namespace));
+    $connection = new Connection($mock_pdo, array('namespace' => $namespace));
     // Set the driver using our stub class' public property.
     $this->assertEquals($expected, $connection->getDriverClass($class));
   }
@@ -204,7 +204,7 @@ public function providerSchema() {
    */
   public function testSchema($expected, $driver, $namespace) {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    $connection = new StubConnection($mock_pdo, array('namespace' => $namespace));
+    $connection = new Connection($mock_pdo, array('namespace' => $namespace));
     $connection->driver = $driver;
     $this->assertInstanceOf($expected, $connection->schema());
   }
@@ -214,9 +214,9 @@ public function testSchema($expected, $driver, $namespace) {
    */
   public function testDestroy() {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    // Mocking StubConnection gives us access to the $schema attribute.
+    // Mocking Connection gives us access to the $schema attribute.
     $connection = $this->getMock(
-      'Drupal\Tests\Core\Database\Stub\StubConnection',
+      'Drupal\Tests\Core\Database\Stub\Connection',
       NULL,
       array($mock_pdo, array('namespace' => 'Drupal\\Tests\\Core\\Database\\Stub\\Driver'))
     );
@@ -261,7 +261,7 @@ public function providerMakeComments() {
    */
   public function testMakeComments($expected, $comment_array) {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    $connection = new StubConnection($mock_pdo, array());
+    $connection = new Connection($mock_pdo, array());
     $this->assertEquals($expected, $connection->makeComment($comment_array));
   }
 
@@ -288,10 +288,10 @@ public function providerFilterComments() {
    */
   public function testFilterComments($expected, $comment) {
     $mock_pdo = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
-    $connection = new StubConnection($mock_pdo, array());
+    $connection = new Connection($mock_pdo, array());
 
     // filterComment() is protected, so we make it accessible with reflection.
-    $reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\StubConnection');
+    $reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\Connection');
     $filter_comment = $reflection->getMethod('filterComment');
     $filter_comment->setAccessible(TRUE);
 
diff --git a/core/tests/Drupal/Tests/Core/Database/DatabaseTest.php b/core/tests/Drupal/Tests/Core/Database/DatabaseTest.php
new file mode 100644
index 0000000..44c48e1
--- /dev/null
+++ b/core/tests/Drupal/Tests/Core/Database/DatabaseTest.php
@@ -0,0 +1,173 @@
+<?php
+
+namespace Drupal\Tests\Core\Database;
+
+use Drupal\Core\Database\Database;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * @coversDefaultClass \Drupal\Core\Database\Database
+ * @group Database
+ */
+class DatabaseTest extends UnitTestCase {
+
+	/**
+	 * @covers ::convertDbUrlToConnectionInfo
+	 */
+	public function testNonExistentDriver() {
+		$this->setExpectedException(\RuntimeException::class, 'Can not convert blah://foo/bar to a database connection, class Drupal\Core\Database\Driver\blah\Connection does not exist');
+		Database::convertDbUrlToConnectionInfo('blah://foo/bar', '\root');
+	}
+
+	/**
+	 * @covers ::convertDbUrlToConnectionInfo
+	 */
+	public function testMalformedUrl() {
+		$this->setExpectedException(\InvalidArgumentException::class, 'Minimum requirement: driver://host/database');
+		Database::convertDbUrlToConnectionInfo('foo/bar', '\root');
+	}
+
+	/**
+	 * @covers ::convertDbUrlToConnectionInfo
+	 */
+	public function testNoConnectionInfo() {
+		$this->setExpectedException(\RuntimeException::class, 'Database connection default not defined');
+		Database::getConnectionInfoAsUrl();
+	}
+
+	/**
+	 * @covers ::convertDbUrlToConnectionInfo
+	 * @dataProvider providerTestconvertDbUrlToConnectionInfo
+	 */
+	public function testconvertDbUrlToConnectionInfo($url, array $expected) {
+		$connection_options = Database::convertDbUrlToConnectionInfo($url, '/root');
+		$this->assertSame($expected, $connection_options);
+	}
+
+	/**
+	 * Data provider for self::testconvertDbUrlToConnectionInfo().
+	 */
+	public function providerTestconvertDbUrlToConnectionInfo() {
+		$data = $this->baseConnectionConvertProviderData();
+		$data[] = [
+			'sqlite://localhost/database_file',
+			[
+				'driver' => 'sqlite',
+				'database' => '/root/database_file',
+				'prefix' => NULL,
+				'namespace' => '',
+			],
+		];
+		return $data;
+	}
+
+	/**
+	 * @covers ::getConnectionInfoAsUrl
+	 * @dataProvider providerGetConnectionInfoAsUrl
+	 */
+	public function testGetConnectionInfoAsUrl($expected, array $connection_options) {
+		Database::setMultipleConnectionInfo(
+			['default' => ['default' => $connection_options]]
+		);
+		$uri = Database::getConnectionInfoAsUrl();
+		// Clean up the static.
+		Database::removeConnection('default');
+		$this->assertSame($expected, $uri);
+	}
+
+	/**
+	 * Data provider for self::testGetConnectionInfoAsUrl().
+	 */
+	public function providerGetConnectionInfoAsUrl() {
+		$data = $this->baseConnectionConvertProviderData();
+		$data[] = [
+			'sqlite://localhost/database_file',
+			[
+				'driver' => 'sqlite',
+				'database' => 'database_file',
+				'prefix' => NULL,
+				'namespace' => '',
+			],
+		];
+		return $data;
+	}
+
+	/**
+	 * Creates a generic set of data to test
+	 */
+	protected function baseConnectionConvertProviderData() {
+		return [
+			[
+				'mysql://username:password@database_server/database_name',
+				[
+					'driver' => 'mysql',
+					'host' => 'database_server',
+					'database' => 'database_name',
+					'prefix' => NULL,
+					'namespace' => '',
+					'username' => 'username',
+					'password' => 'password',
+				],
+			],
+			[
+				'mysql://database_server/database_name',
+				[
+					'driver' => 'mysql',
+					'host' => 'database_server',
+					'database' => 'database_name',
+					'prefix' => NULL,
+					'namespace' => '',
+					'username' => '',
+					'password' => '',
+				],
+			],
+			[
+				'pgsql://username:password@database_server:9999/database_name',
+				[
+					'driver' => 'pgsql',
+					'host' => 'database_server',
+					'database' => 'database_name',
+					'prefix' => NULL,
+					'namespace' => '',
+					'port' => 9999,
+					'username' => 'username',
+					'password' => 'password',
+				],
+			],
+			[
+				'sqlite://localhost//absolute/database_file',
+				[
+					'driver' => 'sqlite',
+					'database' => '/absolute/database_file',
+					'prefix' => NULL,
+					'namespace' => '',
+				],
+			],
+			[
+				'mysql://username:password@database_server/database_name#prefix',
+				[
+					'driver' => 'mysql',
+					'host' => 'database_server',
+					'database' => 'database_name',
+					'prefix' => 'prefix',
+					'namespace' => '',
+					'username' => 'username',
+					'password' => 'password',
+				],
+			],
+			[
+				'stub://username:password@database_server/database_name?namespace=%5CDrupal%5CTests%5CCore%5CDatabase%5CStub',
+				[
+					'driver' => 'stub',
+					'host' => 'database_server',
+					'database' => 'database_name',
+					'prefix' => NULL,
+					'namespace' => '\Drupal\Tests\Core\Database\Stub',
+					'username' => 'username',
+					'password' => 'password',
+				],
+			],
+		];
+	}
+
+}
diff --git a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php b/core/tests/Drupal/Tests/Core/Database/Stub/Connection.php
similarity index 86%
rename from core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php
rename to core/tests/Drupal/Tests/Core/Database/Stub/Connection.php
index 7c93497..faedac1 100644
--- a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php
+++ b/core/tests/Drupal/Tests/Core/Database/Stub/Connection.php
@@ -1,8 +1,13 @@
 <?php
 
+/**
+ * @file
+ * Contains \Drupal\Tests\Core\Database\Stub\Connection.
+ */
+
 namespace Drupal\Tests\Core\Database\Stub;
 
-use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Connection as DatabaseConnection;
 use Drupal\Core\Database\StatementEmpty;
 
 /**
@@ -10,7 +15,7 @@
  *
  * Includes minimal implementations of Connection's abstract methods.
  */
-class StubConnection extends Connection {
+class Connection extends DatabaseConnection {
 
   /**
    * Public property so we can test driver loading mechanism.
