function ConfigTranslationUiTest::testLocaleDBStorage
Same name in other branches
- 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testLocaleDBStorage()
- 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testLocaleDBStorage()
- 11.x core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testLocaleDBStorage()
Tests translation storage in locale storage.
File
-
core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiTest.php, line 200
Class
- ConfigTranslationUiTest
- Translate settings and entities to various languages.
Namespace
Drupal\Tests\config_translation\FunctionalCode
public function testLocaleDBStorage() : void {
// 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();
$this->drupalLogin($this->adminUser);
$langcode = 'xx';
$name = $this->randomMachineName(16);
$edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => Language::DIRECTION_LTR,
];
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add custom language');
// Make sure there is no translation stored in locale storage before edit.
$translation = $this->getTranslation('user.settings', 'anonymous', 'fr');
$this->assertEmpty($translation);
// Add custom translation.
$edit = [
'translation[config_names][user.settings][anonymous]' => 'Anonyme',
];
$this->drupalGet('admin/config/people/accounts/translate/fr/add');
$this->submitForm($edit, 'Save translation');
// Make sure translation stored in locale storage after saved language
// specific configuration translation.
$translation = $this->getTranslation('user.settings', 'anonymous', 'fr');
$this->assertEquals('Anonyme', $translation->getString());
// Revert custom translations to base translation.
$edit = [
'translation[config_names][user.settings][anonymous]' => 'Anonymous',
];
$this->drupalGet('admin/config/people/accounts/translate/fr/edit');
$this->submitForm($edit, 'Save translation');
// Make sure there is no translation stored in locale storage after revert.
$translation = $this->getTranslation('user.settings', 'anonymous', 'fr');
$this->assertEquals('Anonymous', $translation->getString());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.