You are here

protected function InstallerExistingSettingsReadOnlyMismatchProfileTest::prepareEnvironment in Drupal 8

Configures a preexisting settings.php file without an install_profile setting before invoking the interactive installer.

Overrides FunctionalTestSetupTrait::prepareEnvironment

File

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

Class

InstallerExistingSettingsReadOnlyMismatchProfileTest
Tests installer breaks with a profile mismatch and a read-only settings.php.

Namespace

Drupal\FunctionalTests\Installer

Code

protected function prepareEnvironment() {
  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,
  ];

  // During interactive install we'll change this to a different profile and
  // this test will ensure that the new value is written to settings.php.
  $this->settings['settings']['install_profile'] = (object) [
    'value' => 'minimal',
    'required' => TRUE,
  ];

  // Pre-configure config directories.
  $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
  $this->settings['settings']['config_sync_directory'] = (object) [
    'value' => $site_path . '/files/config_staging',
    'required' => TRUE,
  ];
  mkdir($this->settings['settings']['config_sync_directory']->value, 0777, TRUE);
}