protected function WebTestBase::writeSettings

Writes a test-specific settings.php file for the child site.

The child site loads this after the parent site's settings.php, so settings here override those.

Parameters

$settings An array of settings to write out, in the format expected: by drupal_rewrite_settings().

See also

_drupal_load_test_overrides()

drupal_rewrite_settings()

6 calls to WebTestBase::writeSettings()
BareMinimalAnonymousUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalAnonymousUpgradePathTest.php
Overrides \Drupal\system\Tests\Upgrade\UpgradePathTestBase::setUp().
BareMinimalNoConfigUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalNoConfigUpgradePathTest.php
Overrides \Drupal\system\Tests\Upgrade\UpgradePathTestBase::setUp().
InstallerTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/InstallerTest.php
Sets up a Drupal site for running functional and integration tests.
PageCacheTest::testPageCache in drupal/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php
Tests cache headers.
SessionHttpsTest::testHttpsSession in drupal/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 893
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function writeSettings($settings) {

  // drupal_rewrite_settings() sets the in-memory global variables in addition
  // to writing the file. We'll want to restore the original globals.
  foreach (array_keys($settings) as $variable_name) {
    $original_globals[$variable_name] = isset($GLOBALS[$variable_name]) ? $GLOBALS[$variable_name] : NULL;
  }
  include_once DRUPAL_ROOT . '/core/includes/install.inc';
  $filename = $this->public_files_directory . '/settings.php';
  file_put_contents($filename, "<?php\n");
  drupal_rewrite_settings($settings, $filename);

  // Restore the original globals.
  foreach ($original_globals as $variable_name => $value) {
    $GLOBALS[$variable_name] = $value;
  }
}