You are here

public function LocaleUpdateTest::testUpdateImportModeNone 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::testUpdateImportModeNone()
  2. 9 core/modules/locale/tests/src/Functional/LocaleUpdateTest.php \Drupal\Tests\locale\Functional\LocaleUpdateTest::testUpdateImportModeNone()

Tests translation import and don't overwrite any translation.

Test conditions:

  • Source: remote and local files
  • Import overwrite: don't overwrite any existing translation

File

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

Class

LocaleUpdateTest
Tests for updating the interface translations of projects.

Namespace

Drupal\Tests\locale\Functional

Code

public function testUpdateImportModeNone() {
  $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_NONE,
  ];
  $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
    ->assertTranslation('January', 'Januar_customized', 'de');
  $this
    ->assertTranslation('February', 'Februar_customized', 'de');
  $this
    ->assertTranslation('March', 'Marz', 'de');
  $this
    ->assertTranslation('April', 'April_2', 'de');
  $this
    ->assertTranslation('May', 'Mai_customized', 'de');
  $this
    ->assertTranslation('June', 'Juni', 'de');
  $this
    ->assertTranslation('Monday', 'Montag', 'de');

  // cSpell:enable
}