You are here

protected function WebTestBase::initConfig in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::initConfig()

Initialize various configurations post-installation.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: The container.

2 calls to WebTestBase::initConfig()
UpdatePathTestBase::setUp in core/modules/system/src/Tests/Update/UpdatePathTestBase.php
Overrides WebTestBase::setUp() for update testing.
WebTestBase::setUp in core/modules/simpletest/src/WebTestBase.php
Sets up a Drupal site for running functional and integration tests.

File

core/modules/simpletest/src/WebTestBase.php, line 821
Contains \Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function initConfig(ContainerInterface $container) {
  $config = $container
    ->get('config.factory');

  // Manually create and configure private and temporary files directories.
  // While these could be preset/enforced in settings.php like the public
  // files directory above, some tests expect them to be configurable in the
  // UI. If declared in settings.php, they would no longer be configurable.
  file_prepare_directory($this->privateFilesDirectory, FILE_CREATE_DIRECTORY);
  file_prepare_directory($this->tempFilesDirectory, FILE_CREATE_DIRECTORY);
  $config
    ->getEditable('system.file')
    ->set('path.temporary', $this->tempFilesDirectory)
    ->save();

  // Manually configure the test mail collector implementation to prevent
  // tests from sending out emails and collect them in state instead.
  // While this should be enforced via settings.php prior to installation,
  // some tests expect to be able to test mail system implementations.
  $config
    ->getEditable('system.mail')
    ->set('interface.default', 'test_mail_collector')
    ->save();

  // By default, verbosely display all errors and disable all production
  // environment optimizations for all tests to avoid needless overhead and
  // ensure a sane default experience for test authors.
  // @see https://www.drupal.org/node/2259167
  $config
    ->getEditable('system.logging')
    ->set('error_level', 'verbose')
    ->save();
  $config
    ->getEditable('system.performance')
    ->set('css.preprocess', FALSE)
    ->set('js.preprocess', FALSE)
    ->save();

  // Set an explicit time zone to not rely on the system one, which may vary
  // from setup to setup. The Australia/Sydney time zone is chosen so all
  // tests are run using an edge case scenario (UTC+10 and DST). This choice
  // is made to prevent time zone related regressions and reduce the
  // fragility of the testing system in general.
  $config
    ->getEditable('system.date')
    ->set('timezone.default', 'Australia/Sydney')
    ->save();
}