You are here

protected function FunctionalTestSetupTrait::initConfig in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initConfig()
  2. 9 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initConfig()

Initialize various configurations post-installation.

Parameters

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

3 calls to FunctionalTestSetupTrait::initConfig()
BrowserTestBase::installDrupal in core/tests/Drupal/Tests/BrowserTestBase.php
Installs Drupal into the test site.
TestSiteInstallCommand::installDrupal in core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php
Installs Drupal into the test site.
UpdatePathTestBase::installDrupal in core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
Installs Drupal into the test site.

File

core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php, line 327

Class

FunctionalTestSetupTrait
Defines a trait for shared functional test setup functionality.

Namespace

Drupal\Core\Test

Code

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

  // Manually create the private directory.
  \Drupal::service('file_system')
    ->prepareDirectory($this->privateFilesDirectory, FileSystemInterface::CREATE_DIRECTORY);

  // 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 (UTC10 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();
}