function FunctionalTestSetupTrait::initConfig
Initialize various configurations post-installation.
Parameters
\Symfony\Component\DependencyInjection\ContainerInterface $container: The container.
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();
}