You are here

public function LocaleUpdateTest::testUpdateImportModeNonCustomized in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Functional/LocaleUpdateTest.php \Drupal\Tests\locale\Functional\LocaleUpdateTest::testUpdateImportModeNonCustomized()
  2. 9 core/modules/locale/tests/src/Functional/LocaleUpdateTest.php \Drupal\Tests\locale\Functional\LocaleUpdateTest::testUpdateImportModeNonCustomized()

Tests translation import and only overwrite non-customized translations.

Test conditions:

  • Source: remote and local files
  • Import overwrite: only overwrite non-customized translations

File

core/modules/locale/tests/src/Functional/LocaleUpdateTest.php, line 245

Class

LocaleUpdateTest
Tests for updating the interface translations of projects.

Namespace

Drupal\Tests\locale\Functional

Code

public function testUpdateImportModeNonCustomized() {
  $config = $this
    ->config('locale.settings');

  // Build the test environment.
  $this
    ->setTranslationFiles();
  $this
    ->setCurrentTranslations();
  $config
    ->set('translation.default_filename', '%project-%version.%language._po');

  // Set the test conditions.
  $edit = [
    'use_source' => LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL,
    'overwrite' => LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED,
  ];
  $this
    ->drupalGet('admin/config/regional/translate/settings');
  $this
    ->submitForm($edit, 'Save configuration');

  // Execute translation update.
  $this
    ->drupalGet('admin/reports/translations/check');
  $this
    ->drupalGet('admin/reports/translations');
  $this
    ->submitForm([], 'Update translations');

  // Check whether existing translations have (not) been overwritten.
  // cSpell:disable
  $this
    ->assertEquals('Januar_customized', t('January', [], [
    'langcode' => 'de',
  ]), 'Translation of January');
  $this
    ->assertEquals('Februar_customized', t('February', [], [
    'langcode' => 'de',
  ]), 'Translation of February');
  $this
    ->assertEquals('Marz_2', t('March', [], [
    'langcode' => 'de',
  ]), 'Translation of March');
  $this
    ->assertEquals('April_2', t('April', [], [
    'langcode' => 'de',
  ]), 'Translation of April');
  $this
    ->assertEquals('Mai_customized', t('May', [], [
    'langcode' => 'de',
  ]), 'Translation of May');
  $this
    ->assertEquals('Juni', t('June', [], [
    'langcode' => 'de',
  ]), 'Translation of June');
  $this
    ->assertEquals('Montag', t('Monday', [], [
    'langcode' => 'de',
  ]), 'Translation of Monday');

  // cSpell:enable
}