function InstallerExistingBrokenDatabaseSettingsTest::prepareEnvironment

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Installer/InstallerExistingBrokenDatabaseSettingsTest.php \Drupal\FunctionalTests\Installer\InstallerExistingBrokenDatabaseSettingsTest::prepareEnvironment()
  2. 8.9.x core/tests/Drupal/FunctionalTests/Installer/InstallerExistingBrokenDatabaseSettingsTest.php \Drupal\FunctionalTests\Installer\InstallerExistingBrokenDatabaseSettingsTest::prepareEnvironment()
  3. 11.x core/tests/Drupal/FunctionalTests/Installer/InstallerExistingBrokenDatabaseSettingsTest.php \Drupal\FunctionalTests\Installer\InstallerExistingBrokenDatabaseSettingsTest::prepareEnvironment()

Prepares the current environment for running the test.

Also sets up new resources for the testing environment, such as the public filesystem and configuration directories.

Overrides FunctionalTestSetupTrait::prepareEnvironment

File

core/tests/Drupal/FunctionalTests/Installer/InstallerExistingBrokenDatabaseSettingsTest.php, line 24

Class

InstallerExistingBrokenDatabaseSettingsTest
Tests the installer with broken database connection info in settings.php.

Namespace

Drupal\FunctionalTests\Installer

Code

protected function prepareEnvironment() {
  parent::prepareEnvironment();
  // Pre-configure database credentials in settings.php.
  $connection_info = Database::getConnectionInfo();
  if ($connection_info['default']['driver'] !== 'mysql') {
    $this->markTestSkipped('This test relies on overriding the mysql driver');
  }
  // Use a database driver that reports a fake database version that does
  // not meet requirements.
  unset($connection_info['default']['pdo']);
  unset($connection_info['default']['init_commands']);
  $connection_info['default']['driver'] = 'DrivertestMysqlDeprecatedVersion';
  $namespace = 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion';
  $connection_info['default']['namespace'] = $namespace;
  $connection_info['default']['autoload'] = \Drupal::service('extension.list.database_driver')->get($namespace)
    ->getAutoloadInfo()['autoload'];
  $this->settings['databases']['default'] = (object) [
    'value' => $connection_info,
    'required' => TRUE,
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.