protected function LocaleConfigSubscriberTest::setUpTranslation in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php \Drupal\locale\Tests\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/ src/ Tests/ LocaleConfigSubscriberForeignTest.php - Sets up the locale storage strings to be in line with configuration.
- LocaleConfigSubscriberTest::setUpLocale in core/
modules/ locale/ src/ Tests/ LocaleConfigSubscriberTest.php - Sets up the locale storage strings to be in line with configuration.
File
- core/
modules/ locale/ src/ Tests/ LocaleConfigSubscriberTest.php, line 219 - Contains \Drupal\locale\Tests\LocaleConfigSubscriberTest.
Class
- LocaleConfigSubscriberTest
- Tests that shipped configuration translations are updated correctly.
Namespace
Drupal\locale\TestsCode
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(array(
$config_name,
), array(
$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);
}