diff --git a/core/includes/install.inc b/core/includes/install.inc
index 3529d51..21f75fb 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Component\Utility\Unicode;
+use Drupal\Core\Database\DatabaseDriverDiscovery;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Drupal\Component\Utility\Crypt;
 use Drupal\Component\Utility\OpCodeCache;
@@ -141,15 +142,17 @@ function drupal_install_profile_distribution_version() {
  *
  * @return
  *   An array of database types compiled into PHP.
+ *
+ * @deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use
+ *   \Drupal\Core\Database\DatabaseDriverDiscovery::detectDatabaseTypes
+ *   instead.
+ *
+ * @see https://www.drupal.org/node/2896416
  */
 function drupal_detect_database_types() {
-  $databases = drupal_get_database_types();
-
-  foreach ($databases as $driver => $installer) {
-    $databases[$driver] = $installer->name();
-  }
-
-  return $databases;
+  @trigger_error('drupal_detect_database_types() is deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\DatabaseDriverDiscovery::detectDatabaseTypes instead. See https://www.drupal.org/node/2896416.', E_USER_DEPRECATED);
+  $discovery = new DatabaseDriverDiscovery();
+  return $discovery->detectDatabaseTypes();
 }
 
 /**
@@ -157,37 +160,16 @@ function drupal_detect_database_types() {
  *
  * @return \Drupal\Core\Database\Install\Tasks[]
  *   An array of available database driver installer objects.
+ *
+ * @deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use
+ *   \Drupal\Core\Database\DatabaseDriverDiscovery::getDatabaseTypes instead.
+ *
+ * @see https://www.drupal.org/node/2896416
  */
 function drupal_get_database_types() {
-  $databases = [];
-  $drivers = [];
-
-  // The internal database driver name is any valid PHP identifier.
-  $mask = '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '$/';
-  $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, ['recurse' => FALSE]);
-  if (is_dir(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database')) {
-    $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, ['recurse' => FALSE]);
-  }
-  foreach ($files as $file) {
-    if (file_exists($file->uri . '/Install/Tasks.php')) {
-      $drivers[$file->filename] = $file->uri;
-    }
-  }
-  foreach ($drivers as $driver => $file) {
-    $installer = db_installer_object($driver);
-    if ($installer->installable()) {
-      $databases[$driver] = $installer;
-    }
-  }
-
-  // Usability: unconditionally put the MySQL driver on top.
-  if (isset($databases['mysql'])) {
-    $mysql_database = $databases['mysql'];
-    unset($databases['mysql']);
-    $databases = ['mysql' => $mysql_database] + $databases;
-  }
-
-  return $databases;
+  @trigger_error('drupal_get_database_types() is deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\DatabaseDriverDiscovery::getDatabaseTypes instead. See https://www.drupal.org/node/2896416.', E_USER_DEPRECATED);
+  $discovery = new DatabaseDriverDiscovery();
+  return $discovery->getDatabaseTypes();
 }
 
 /**
@@ -1107,16 +1089,14 @@ function install_profile_info($profile, $langcode = 'en') {
  *
  * @return \Drupal\Core\Database\Install\Tasks
  *   A class defining the requirements and tasks for installing the database.
+ *
+ * @deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use
+ *   \Drupal\Core\Database\DatabaseDriverDiscovery::getInstallerObject instead.
+ *
+ * @see https://www.drupal.org/node/2896416
  */
 function db_installer_object($driver) {
-  // We cannot use Database::getConnection->getDriverClass() here, because
-  // the connection object is not yet functional.
-  $task_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Install\\Tasks";
-  if (class_exists($task_class)) {
-    return new $task_class();
-  }
-  else {
-    $task_class = "Drupal\\Driver\\Database\\{$driver}\\Install\\Tasks";
-    return new $task_class();
-  }
+  @trigger_error('drupal_get_database_types() is deprecated in Drupal 8.5.0, will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\DatabaseDriverDiscovery::getInstallerObject instead. See https://www.drupal.org/node/2896416.', E_USER_DEPRECATED);
+  $discovery = new DatabaseDriverDiscovery();
+  return $discovery->getInstallerObject($driver);
 }
diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 100ef68..7ab5f2c 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 Psr\Http\Message\UriInterface;
+
 /**
  * Base Database API class.
  *
@@ -1472,4 +1474,62 @@ 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.
+   *
+   * @internal
+   *   This method should not be called. Use
+   *   \Drupal\Core\Database\Database::convertDbUrlToConnectionInfo() instead.
+   *
+   * @param \Psr\Http\Message\UriInterface $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(UriInterface $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.
+   *
+   * @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 \Psr\Http\Message\UriInterface $uri
+   *   The URI to connect to the database.
+   *
+   * @return $this|\Psr\Http\Message\UriInterface
+   *   The URI to connect to the database.
+   *
+   * @see \Drupal\Core\Database\Database::getConnectionInfoAsUrl()
+   */
+  public static function getConnectionInfoAsUrlHelper(array $connection_options, UriInterface $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 dd19018..f2d841a 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.
  *
@@ -365,13 +367,8 @@
       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";
-    }
+    $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]);
@@ -455,36 +452,35 @@ public static function ignoreTarget($key, $target) {
    *   requirements.
    */
   public static function convertDbUrlToConnectionInfo($url, $root) {
-    $info = parse_url($url);
-    if (!isset($info['scheme'], $info['host'], $info['path'])) {
+    $uri = new Uri($url);
+    if (empty($uri->getHost()) || empty($uri->getScheme()) || empty($uri->getPath())) {
       throw new \InvalidArgumentException('Minimum requirement: driver://host/database');
     }
-    $info += [
-      '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'];
+    // Discover if the URL has a driver namespace.
+    $scheme = $uri->getScheme();
+    $discovery = new DatabaseDriverDiscovery();
+    $drivers = $discovery->discoverDatabaseDrivers();
+    if (!isset($drivers[$scheme])) {
+      throw new \Exception("Drupal database driver not available: '" . $uri->getScheme() . "'");
     }
-
-    $database = [
-      'driver' => $info['scheme'],
-      'username' => $info['user'],
-      'password' => $info['pass'],
-      'host' => $info['host'],
-      'database' => $info['path'],
+    $namespace = $drivers[$scheme]['namespace'];
+    $fragment = $uri->getFragment();
+    $connection_options = [
+      '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,
     ];
-    if (isset($info['port'])) {
-      $database['port'] = $info['port'];
+
+    $driver_class = static::getDatabaseConnectionClass($connection_options['driver'], $connection_options['namespace']);
+    if (!class_exists($driver_class)) {
+      throw new \RuntimeException("Can not convert $url to a database connection, class $driver_class does not exist");
     }
-    return $database;
+    return $driver_class::convertDbUrlToConnectionInfoHelper($uri, $root, $connection_options);
   }
 
   /**
@@ -498,29 +494,64 @@ public static function convertDbUrlToConnectionInfo($url, $root) {
    */
   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'];
+    if (empty($db_info)) {
+      throw new \RuntimeException("Database connection $key not defined");
     }
-    else {
-      $user = '';
-      if ($db_info['default']['username']) {
-        $user = $db_info['default']['username'];
-        if ($db_info['default']['password']) {
-          $user .= ':' . $db_info['default']['password'];
-        }
-        $user .= '@';
-      }
+    return static::convertConnectionInfoToUrl($db_info);
+  }
 
-      $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'];
+  /**
+   * Convert a database connection info array to a URL.
+   *
+   * @param array $db_info
+   *   The database connection info.
+   *
+   * @return string
+   *   The connection info as a URL.
+   */
+  public static function convertConnectionInfoToUrl($db_info) {
+
+    $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();
+    $uri = $uri->withScheme($db_info['default']['driver'])
+      ->withHost($host)
+      ->withPath('/' . $db_info['default']['database']);
+
+    if (!empty($db_info['default']['prefix']['default'])) {
+      $uri = $uri->withFragment($db_info['default']['prefix']['default']);
+    }
+
+    $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';
     }
-    if ($db_info['default']['prefix']['default']) {
-      $db_url .= '#' . $db_info['default']['prefix']['default'];
+    else {
+      // Fallback for Drupal 7 settings.php.
+      $driver_class = 'Drupal\\Core\\Database\\Driver\\' . $driver . '\\Connection';
     }
-    return $db_url;
+    return $driver_class;
   }
 
 }
diff --git a/core/lib/Drupal/Core/Database/DatabaseDriverDiscovery.php b/core/lib/Drupal/Core/Database/DatabaseDriverDiscovery.php
new file mode 100644
index 0000000..0f5a9f2
--- /dev/null
+++ b/core/lib/Drupal/Core/Database/DatabaseDriverDiscovery.php
@@ -0,0 +1,137 @@
+<?php
+
+namespace Drupal\Core\Database;
+
+/**
+ * Component used to perform database driver
+ * discovery.
+ */
+class DatabaseDriverDiscovery {
+
+  /**
+   * The Drupal root.
+   *
+   * @var string
+   */
+  protected $drupalRoot;
+
+  /**
+   * Available locations for drivers
+   *
+   * @var mixed[]
+   */
+  protected $discoveryLocations;
+
+  /**
+   * Get an instance of DatabaseDriverDiscovery.
+   */
+  public function __construct() {
+    // Hard-coded DRUPAL_ROOT (because bootstrap.inc is not accessible).
+    $this->drupalRoot = dirname(dirname(dirname(dirname(dirname(__DIR__)))));
+    // See composer.json for discoverable namespaces.
+    $this->discoveryLocations = [
+      'Drupal\\Core\\Database\\Driver' => '/core/lib/Drupal/Core/Database/Driver',
+      'Drupal\\Driver\\Database' => '/drivers/lib/Drupal/Driver/Database'
+    ];
+  }
+
+  /**
+   * Detects all supported databases that are compiled into PHP.
+   *
+   * @return
+   *   An array of database types compiled into PHP.
+   */
+  public function detectDatabaseTypes() {
+    $databases = $this->getDatabaseTypes();
+
+    foreach ($databases as $driver => $installer) {
+      $databases[$driver] = $installer->name();
+    }
+
+    return $databases;
+  }
+
+  /**
+   * Returns information about available database drivers.
+   *
+   * @return \Drupal\Core\Database\Install\Tasks[]
+   *   An array of available database driver installer objects.
+   */
+  public function getDatabaseTypes() {
+
+    $databases = [];
+
+    foreach ($this->discoverDatabaseDrivers() as $driver => $info) {
+      if ($info['installable'] === TRUE) {
+        $databases[$driver] = $info['installer'];
+      }
+    }
+
+    // Usability: unconditionally put the MySQL driver on top.
+    if (isset($databases['mysql'])) {
+      $mysql_database = $databases['mysql'];
+      unset($databases['mysql']);
+      $databases = ['mysql' => $mysql_database] + $databases;
+    }
+
+    return $databases;
+  }
+
+  /**
+   * Returns a database installer object.
+   *
+   * @param $driver
+   *   The name of the driver.
+   *
+   * @return \Drupal\Core\Database\Install\Tasks
+   *   A class defining the requirements and tasks for installing the database.
+   */
+  public function getInstallerObject($driver) {
+    $drivers = $this->discoverDatabaseDrivers();
+    return $drivers[$driver]['installer'];
+  }
+
+  /**
+   * Discover the available database drivers.
+   */
+  public function discoverDatabaseDrivers() {
+
+    $drivers = [];
+
+    // The internal database driver name is any valid PHP identifier.
+    $files = [];
+    foreach ($this->discoveryLocations as $namespace => $location) {
+      if (is_dir($this->drupalRoot . $location)) {
+        if ($handle = @opendir($this->drupalRoot . $location)) {
+          while (FALSE !== ($driverName = readdir($handle))) {
+            // Skip this file if it matches the nomask or starts with a dot.
+            if ($driverName[0] != '.') {
+              if (isset($files[$driverName])) {
+                throw new \Exception("Conflicting database driver name: " . $driverName);
+              }
+              $files[$driverName] = $namespace . '\\' . $driverName;
+            }
+          }
+        }
+      }
+    }
+
+    foreach ($files as $driver => $namespace) {
+      $drivers[$driver]['namespace'] = $namespace;
+
+      $connectionClass = $namespace . '\\Connection';
+      if (class_exists($connectionClass)) {
+        $drivers[$driver]['connectionClass'] = $connectionClass;
+      }
+
+      $installTasksClass = $namespace . '\\Install\\Tasks';
+      if (class_exists($installTasksClass)) {
+        $installer = new $installTasksClass();
+        $drivers[$driver]['installer'] = $installer;
+        $drivers[$driver]['installable'] = $installer->installable();
+      }
+    }
+
+    return $drivers;
+  }
+}
diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
index a7c1496..6eade7e 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 Psr\Http\Message\UriInterface;
 
 /**
  * SQLite implementation of \Drupal\Core\Database\Connection.
@@ -436,4 +437,30 @@ public function getFullQualifiedTableName($table) {
     return $prefix . $table;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function convertDbUrlToConnectionInfoHelper(UriInterface $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, UriInterface $uri) {
+    if ($connection_options['database'][0] === '/') {
+      // If the database is an 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 0e0ea2a..02ecf8f 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -316,9 +316,11 @@ function simpletest_phpunit_configuration_filepath() {
  */
 function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpunit_file, &$status = NULL, &$output = 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());
+  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/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php b/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php
index cb7f5eb..7604ab4 100644
--- a/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php
+++ b/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php
@@ -1,10 +1,5 @@
 <?php
 
-/**
- * @file
- * Contains \Drupal\Tests\system\Kernel\Scripts\DbCommandBaseTest.
- */
-
 namespace Drupal\Tests\system\Kernel\Scripts;
 
 use Drupal\Core\Command\DbCommandBase;
@@ -58,18 +53,16 @@ public function testSpecifyDatabaseDoesNotExist() {
    * Test supplying database connection as a url.
    */
   public function testSpecifyDbUrl() {
-    $connection_info = Database::getConnectionInfo('default')['default'];
-
     $command = new DbCommandBaseTester();
     $command_tester = new CommandTester($command);
     $command_tester->execute([
-      '-db-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database']
+      '-db-url' => Database::getConnectionInfoAsUrl('default')
     ]);
     $this->assertEquals('db-tools', $command->getDatabaseConnection($command_tester->getInput())->getKey());
 
     Database::removeConnection('db-tools');
     $command_tester->execute([
-      '--database-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database']
+      '--database-url' => Database::getConnectionInfoAsUrl('default')
     ]);
     $this->assertEquals('db-tools', $command->getDatabaseConnection($command_tester->getInput())->getKey());
   }
@@ -91,9 +84,8 @@ public function testPrefix() {
     ]);
     $this->assertEquals('extra', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
 
-    $connection_info = Database::getConnectionInfo('default')['default'];
     $command_tester->execute([
-      '-db-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database'],
+      '-db-url' => Database::getConnectionInfoAsUrl('default'),
       '--prefix' => 'extra2',
     ]);
     $this->assertEquals('extra2', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index ca1a517..82e1036 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -462,7 +462,7 @@ protected function getDatabaseConnectionInfo() {
         // Replace the full table prefix definition to ensure that no table
         // prefixes of the test runner leak into the test.
         $connection_info[$target]['prefix'] = [
-          'default' => $value['prefix']['default'] . $this->databasePrefix,
+          'default' => $this->databasePrefix,
         ];
       }
     }
diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
index e455847..74e30ae 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, []);
+    $connection = new Connection($mock_pdo, []);
 
     // 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, ['prefix' => $prefix_info]);
+    $connection = new Connection($mock_pdo, ['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, []);
+    $connection = new Connection($mock_pdo, []);
     $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, ['namespace' => $namespace]);
+    $connection = new Connection($mock_pdo, ['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, ['namespace' => $namespace]);
+    $connection = new Connection($mock_pdo, ['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,
       [$mock_pdo, ['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, []);
+    $connection = new Connection($mock_pdo, []);
     $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, []);
+    $connection = new Connection($mock_pdo, []);
 
     // 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/Stub/Connection.php b/core/tests/Drupal/Tests/Core/Database/Stub/Connection.php
new file mode 100644
index 0000000..06500f7
--- /dev/null
+++ b/core/tests/Drupal/Tests/Core/Database/Stub/Connection.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace Drupal\Tests\Core\Database\Stub;
+
+use Drupal\Core\Database\Connection as DatabaseConnection;
+use Drupal\Core\Database\StatementEmpty;
+
+/**
+ * A stub of the abstract Connection class for testing purposes.
+ *
+ * Includes minimal implementations of Connection's abstract methods.
+ */
+class Connection extends DatabaseConnection {
+
+  /**
+   * Public property so we can test driver loading mechanism.
+   *
+   * @var string
+   * @see driver().
+   */
+  public $driver = 'stub';
+
+  /**
+   * {@inheritdoc}
+   */
+  public function queryRange($query, $from, $count, array $args = [], array $options = []) {
+    return new StatementEmpty();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function queryTemporary($query, array $args = [], array $options = []) {
+    return '';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function driver() {
+    return $this->driver;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function databaseType() {
+    return 'stub';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function createDatabase($database) {
+    return;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function mapConditionOperator($operator) {
+    return NULL;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function nextId($existing_id = 0) {
+    return 0;
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php b/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php
deleted file mode 100644
index 4692dff..0000000
--- a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-namespace Drupal\Tests\Core\Database\Stub;
-
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Database\StatementEmpty;
-
-/**
- * A stub of the abstract Connection class for testing purposes.
- *
- * Includes minimal implementations of Connection's abstract methods.
- */
-class StubConnection extends Connection {
-
-  /**
-   * Public property so we can test driver loading mechanism.
-   *
-   * @var string
-   * @see driver().
-   */
-  public $driver = 'stub';
-
-  /**
-   * {@inheritdoc}
-   */
-  public function queryRange($query, $from, $count, array $args = [], array $options = []) {
-    return new StatementEmpty();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function queryTemporary($query, array $args = [], array $options = []) {
-    return '';
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function driver() {
-    return $this->driver;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function databaseType() {
-    return 'stub';
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function createDatabase($database) {
-    return;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function mapConditionOperator($operator) {
-    return NULL;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function nextId($existing_id = 0) {
-    return 0;
-  }
-
-}
diff --git a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
index c514b2e..8b764ef 100644
--- a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
@@ -37,25 +37,25 @@ public function providerConvertDbUrlToConnectionInfo() {
     $url1 = 'mysql://test_user:test_pass@test_host:3306/test_database';
     $database_array1 = [
       'driver' => 'mysql',
-      'username' => 'test_user',
-      'password' => 'test_pass',
       'host' => 'test_host',
       'database' => 'test_database',
-      'port' => '3306',
+      'prefix' => NULL,
+      'port' => 3306,
+      'username' => 'test_user',
+      'password' => 'test_pass',
+      'namespace' => 'Drupal\Core\Database\Driver\mysql',
     ];
     $root2 = '/var/www/d8';
     $url2 = 'sqlite://test_user:test_pass@test_host:3306/test_database';
     $database_array2 = [
       'driver' => 'sqlite',
-      'username' => 'test_user',
-      'password' => 'test_pass',
-      'host' => 'test_host',
       'database' => $root2 . '/test_database',
-      'port' => 3306,
+      'prefix' => NULL,
+      'namespace' => 'Drupal\Core\Database\Driver\sqlite',
     ];
     return [
       [$root1, $url1, $database_array1],
-      [$root2, $url2, $database_array2],
+      [$root2, $url2, $database_array2]
     ];
   }
 
@@ -122,7 +122,6 @@ public function providerGetConnectionInfoAsUrl() {
       'prefix' => '',
       'host' => 'test_host',
       'port' => '3306',
-      'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
       'driver' => 'mysql',
     ];
     $expected_url1 = 'mysql://test_user:test_pass@test_host:3306/test_database';
