function FunctionalTestSetupTrait::initConfig
Same name in other branches
- 9 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initConfig()
- 8.9.x core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initConfig()
- 11.x 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.
4 calls to FunctionalTestSetupTrait::initConfig()
- BrowserTestBase::installDrupal in core/
tests/ Drupal/ Tests/ BrowserTestBase.php - Installs Drupal into the test 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 - Overrides BrowserTestBase::installDrupal() for update testing.
1 method overrides FunctionalTestSetupTrait::initConfig()
- MediaSourceOEmbedVideoTest::initConfig in core/
modules/ media/ tests/ src/ FunctionalJavascript/ MediaSourceOEmbedVideoTest.php - Initialize various configurations post-installation.
File
-
core/
lib/ Drupal/ Core/ Test/ FunctionalTestSetupTrait.php, line 343
Class
- FunctionalTestSetupTrait
- Defines a trait for shared functional test setup functionality.
Namespace
Drupal\Core\TestCode
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')
->set('mailer_dsn', [
'scheme' => 'null',
'host' => 'null',
'user' => NULL,
'password' => NULL,
'port' => NULL,
'options' => [],
])
->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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.