You are here

protected function ControllerTest::writeSettings in MongoDB 8.2

Rewrites the settings.php file of the test site.

Parameters

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

Throws

\Exception

Overrides FunctionalTestSetupTrait::writeSettings

See also

\Drupal\Core\Test\FunctionalTestSetupTrait::writeSettings()

File

modules/mongodb_watchdog/tests/src/Functional/ControllerTest.php, line 215

Class

ControllerTest
Test the MongoDB report controllers.

Namespace

Drupal\Tests\mongodb_watchdog\Functional

Code

protected function writeSettings(array $settings) {

  // Taken from trait.
  include_once DRUPAL_ROOT . '/core/includes/install.inc';
  $filename = $this->siteDirectory . '/settings.php';

  // Customizations.
  $settings['settings'] += [
    MongoDb::MODULE => (object) [
      'value' => $this
        ->getSettingsArray(),
      'required' => TRUE,
    ],
  ];

  // End of code taken from trait again.
  // system_requirements() removes write permissions from settings.php
  // whenever it is invoked.
  // Not using File API; a potential error must trigger a PHP warning.
  chmod($filename, 0666);
  drupal_rewrite_settings($settings, $filename);
}