function LocaleConfigTranslationTest::setUp
Same name in other branches
- 9 core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php \Drupal\Tests\locale\Functional\LocaleConfigTranslationTest::setUp()
- 10 core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php \Drupal\Tests\locale\Functional\LocaleConfigTranslationTest::setUp()
- 11.x core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php \Drupal\Tests\locale\Functional\LocaleConfigTranslationTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ locale/ tests/ src/ Functional/ LocaleConfigTranslationTest.php, line 37
Class
- LocaleConfigTranslationTest
- Tests translation of configuration strings.
Namespace
Drupal\Tests\locale\FunctionalCode
protected function setUp() {
parent::setUp();
// Add a default locale storage for all these tests.
$this->storage = $this->container
->get('locale.storage');
// Enable import of translations. By default this is disabled for automated
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
// Add custom language.
$this->langcode = 'xx';
$admin_user = $this->drupalCreateUser([
'administer languages',
'access administration pages',
'translate interface',
'administer modules',
'access site-wide contact form',
'administer contact forms',
'administer site configuration',
]);
$this->drupalLogin($admin_user);
$name = $this->randomMachineName(16);
$edit = [
'predefined_langcode' => 'custom',
'langcode' => $this->langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
// Set path prefix.
$edit = [
"prefix[{$this->langcode}]" => $this->langcode,
];
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.