You are here

public function LocaleUpdateTest::testUpdateImportModeNonCustomized in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/locale/tests/src/Functional/LocaleUpdateTest.php \Drupal\Tests\locale\Functional\LocaleUpdateTest::testUpdateImportModeNonCustomized()
  2. 10 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 229

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
    ->drupalPostForm('admin/config/regional/translate/settings', $edit, t('Save configuration'));

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

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