function InstallerExistingSettingsTest::prepareEnvironment

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

Fully configures a preexisting settings.php file before invoking the interactive installer.

Overrides FunctionalTestSetupTrait::prepareEnvironment

1 call to InstallerExistingSettingsTest::prepareEnvironment()
InstallerIsolationLevelExistingSettingsTest::prepareEnvironment in core/modules/mysql/tests/src/Functional/InstallerIsolationLevelExistingSettingsTest.php
Fully configures a preexisting settings.php file before invoking the interactive installer.
1 method overrides InstallerExistingSettingsTest::prepareEnvironment()
InstallerIsolationLevelExistingSettingsTest::prepareEnvironment in core/modules/mysql/tests/src/Functional/InstallerIsolationLevelExistingSettingsTest.php
Fully configures a preexisting settings.php file before invoking the interactive installer.

File

core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php, line 29

Class

InstallerExistingSettingsTest
Tests the installer with an existing settings file.

Namespace

Drupal\FunctionalTests\Installer

Code

protected function prepareEnvironment() : void {
    parent::prepareEnvironment();
    // Pre-configure hash salt.
    // Any string is valid, so simply use the class name of this test.
    $this->settings['settings']['hash_salt'] = (object) [
        'value' => __CLASS__,
        'required' => TRUE,
    ];
    // Pre-configure database credentials.
    $connection_info = Database::getConnectionInfo();
    unset($connection_info['default']['pdo']);
    unset($connection_info['default']['init_commands']);
    $this->settings['databases']['default'] = (object) [
        'value' => $connection_info,
        'required' => TRUE,
    ];
    // Use the kernel to find the site path because the site.path service should
    // not be available at this point in the install process.
    $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
    // Pre-configure config directories.
    $this->settings['settings']['config_sync_directory'] = (object) [
        'value' => $site_path . '/files/config_sync',
        'required' => TRUE,
    ];
    mkdir($this->settings['settings']['config_sync_directory']->value, 0777, TRUE);
}

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