function LocaleConfigSubscriberTest::testUnchangedTranslationNotResaved

Same name and namespace in other branches
  1. main core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::testUnchangedTranslationNotResaved()

Tests that unchanged translations are not re-saved.

Verifies that updateConfigTranslations() skips saving config overrides when the computed translation data is identical to the existing override.

File

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

Class

LocaleConfigSubscriberTest
Tests that shipped configuration translations are updated correctly.

Namespace

Drupal\Tests\locale\Kernel

Code

public function testUnchangedTranslationNotResaved() : void {
  $config_name = 'locale_test.translation';
  // After setUp(), the German override already exists. Calling
  // updateConfigTranslations() again without changes should not re-save it.
  $this->localeConfigManager
    ->reset();
  $count = $this->localeConfigManager
    ->updateConfigTranslations([
    $config_name,
  ], [
    'de',
  ]);
  $this->assertSame(0, $count, 'Unchanged config translation should not be re-saved.');
  // Verify the override is still intact.
  $this->assertConfigOverride($config_name, 'test', 'German test', 'de');
}

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