root); if (in_array($database['driver'], ['mysql', 'pgsql'])) { // Change the used database driver to the one provided by the module // "driver_test". $driver = 'DriverTest' . ucfirst($database['driver']); $database['driver'] = $driver; $database['namespace'] = 'Drupal\\driver_test\\Driver\\Database\\' . $driver; $database['autoload'] = "core/modules/system/tests/modules/driver_test/src/Driver/Database/$driver/"; } Database::addConnectionInfo('default', 'default', $database); } // Clone the current connection and replace the current prefix. $connection_info = Database::getConnectionInfo('default'); if (!empty($connection_info)) { Database::renameConnection('default', 'simpletest_original_default'); foreach ($connection_info as $target => $value) { // Replace the table prefix definition to ensure that no table of the // test runner leak into the test. $connection_info[$target]['prefix'] = $this->databasePrefix; } } return $connection_info; } /** * @covers ::bootEnvironment */ public function testDatabaseDriverModuleEnabled(): void { $driver = Database::getConnection()->driver(); if (!in_array($driver, ['DriverTestMysql', 'DriverTestPgsql'])) { $this->markTestSkipped("This test does not support the {$driver} database driver."); } // Test that the module that is providing the database driver is enabled. $this->assertSame(1, \Drupal::service('extension.list.module')->get('driver_test')->status); } }