function InstallerBrokenDatabasePortSettingsTest::prepareEnvironment

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/Installer/InstallerBrokenDatabasePortSettingsTest.php \Drupal\FunctionalTests\Installer\InstallerBrokenDatabasePortSettingsTest::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/InstallerBrokenDatabasePortSettingsTest.php, line 24

Class

InstallerBrokenDatabasePortSettingsTest
Tests the installer with incorrect 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');
  }
  // Override the port number to random port.
  $connection_info['default']['port'] = 1234;
  $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.