function LocaleConfigSubscriberTest::saveLanguageOverride

Same name in other branches
  1. 8.9.x core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::saveLanguageOverride()
  2. 10 core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::saveLanguageOverride()
  3. 11.x core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::saveLanguageOverride()

Saves a language override.

This will invoke LocaleConfigSubscriber through the event dispatcher. To make sure the configuration was persisted correctly, the configuration value is checked. Because LocaleConfigSubscriber temporarily disables the override state of the configuration factory we check that the correct value is restored afterwards.

Parameters

string $config_name: The configuration name.

string $key: The configuration key.

string|array $value: The configuration value to save.

string $langcode: The language code.

4 calls to LocaleConfigSubscriberTest::saveLanguageOverride()
LocaleConfigSubscriberForeignTest::testEnglish in core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php
Tests that adding English creates a translation override.
LocaleConfigSubscriberTest::testCreateTranslation in core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php
Tests creating translations of shipped configuration.
LocaleConfigSubscriberTest::testCreateTranslationMultiValue in core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php
Tests creating translations configuration with multi value settings.
LocaleConfigSubscriberTest::testUpdateTranslation in core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php
Tests updating translations of shipped configuration.

File

core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php, line 271

Class

LocaleConfigSubscriberTest
Tests that shipped configuration translations are updated correctly.

Namespace

Drupal\Tests\locale\Kernel

Code

protected function saveLanguageOverride($config_name, $key, $value, $langcode) {
    $translation_override = $this->languageManager
        ->getLanguageConfigOverride($langcode, $config_name);
    $translation_override->set($key, $value)
        ->save();
    $this->configFactory
        ->reset($config_name);
    $this->assertConfigOverride($config_name, $key, $value, $langcode);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.