You are here

protected function InstallerExistingSettingsTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php \Drupal\system\Tests\Installer\InstallerExistingSettingsTest::setUp()

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

Overrides InstallerTestBase::setUp

File

core/modules/system/src/Tests/Installer/InstallerExistingSettingsTest.php, line 28
Contains \Drupal\system\Tests\Installer\InstallerExistingSettingsTest.

Class

InstallerExistingSettingsTest
Tests the installer with an existing settings file.

Namespace

Drupal\system\Tests\Installer

Code

protected function setUp() {

  // Pre-configure hash salt.
  // Any string is valid, so simply use the class name of this test.
  $this->settings['settings']['hash_salt'] = (object) array(
    'value' => __CLASS__,
    '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) array(
    'value' => 'minimal',
    '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) array(
    '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['config_directories'] = array(
    CONFIG_SYNC_DIRECTORY => (object) array(
      'value' => $site_path . '/files/config_sync',
      'required' => TRUE,
    ),
  );
  mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
  parent::setUp();
}