protected function LocaleConfigSubscriberTest::setUpTranslation in Drupal 8
Same name and namespace in other branches
- 9 core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::setUpTranslation()
- 10 core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::setUpTranslation()
Sets up a configuration string with a translation.
The actual configuration is already available by installing locale_test module, as it is done in LocaleConfigSubscriberTest::setUp(). This sets up the necessary source and translation strings and verifies that everything is as expected to avoid false positives.
Parameters
string $config_name: The configuration name.
string $key: The configuration key.
string $source: The source string.
string $translation: The translation string.
string $langcode: The language code.
bool $is_active: Whether the update will affect the active configuration.
2 calls to LocaleConfigSubscriberTest::setUpTranslation()
- LocaleConfigSubscriberForeignTest::setUpLocale in core/
modules/ locale/ tests/ src/ Kernel/ LocaleConfigSubscriberForeignTest.php - Sets up the locale storage strings to be in line with configuration.
- LocaleConfigSubscriberTest::setUpLocale in core/
modules/ locale/ tests/ src/ Kernel/ LocaleConfigSubscriberTest.php - Sets up the locale storage strings to be in line with configuration.
File
- core/
modules/ locale/ tests/ src/ Kernel/ LocaleConfigSubscriberTest.php, line 229
Class
- LocaleConfigSubscriberTest
- Tests that shipped configuration translations are updated correctly.
Namespace
Drupal\Tests\locale\KernelCode
protected function setUpTranslation($config_name, $key, $source, $translation, $langcode, $is_active = FALSE) {
// Create source and translation strings for the configuration value and add
// the configuration name as a location. This would be performed by
// locale_translate_batch_import() invoking
// LocaleConfigManager::updateConfigTranslations() normally.
$this->localeConfigManager
->reset();
$this->localeConfigManager
->getStringTranslation($config_name, $langcode, $source, '')
->setString($translation)
->setCustomized(FALSE)
->save();
$this->configFactory
->reset($config_name);
$this->localeConfigManager
->reset();
$this->localeConfigManager
->updateConfigTranslations([
$config_name,
], [
$langcode,
]);
if ($is_active) {
$this
->assertActiveConfig($config_name, $key, $translation, $langcode);
}
else {
$this
->assertConfigOverride($config_name, $key, $translation, $langcode);
}
$this
->assertTranslation($config_name, $translation, $langcode, FALSE);
}