You are here

protected function FunctionalTestSetupTrait::initConfig in Drupal 8

Same name and namespace in other branches
  1. 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.

6 calls to FunctionalTestSetupTrait::initConfig()
BrowserTestBase::installDrupal in core/tests/Drupal/Tests/BrowserTestBase.php
Installs Drupal into the Simpletest site.
MediaSourceOEmbedVideoTest::initConfig in core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
Initialize various configurations post-installation.
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 Simpletest site.
UpdatePathTestBase::setUp in core/modules/system/src/Tests/Update/UpdatePathTestBase.php
Overrides WebTestBase::setUp() for update testing.

... See full list

2 methods override FunctionalTestSetupTrait::initConfig()
MediaSourceOEmbedVideoTest::initConfig in core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
Initialize various configurations post-installation.
WarmCacheUpdateFrom8dot6Test::initConfig in core/modules/system/tests/src/Functional/Update/WarmCacheUpdateFrom8dot6Test.php
Initialize various configurations post-installation.

File

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

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