function LocaleUpdateTest::testUpdateImportModeNone

Tests translation import with a translations directory and don't overwrite any translation.

Test conditions:

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

File

drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php, line 635
Contains Drupal\locale\Tests\LocaleUpdateTest.

Class

LocaleUpdateTest
Tests for update translations.

Namespace

Drupal\locale\Tests

Code

function testUpdateImportModeNone() {
  $config = 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 = array(
    'use_source' => LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL,
    'overwrite' => LOCALE_TRANSLATION_OVERWRITE_NONE,
  );
  $this
    ->drupalPost('admin/config/regional/translate/settings', $edit, t('Save configuration'));

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

  // Check whether existing translations have (not) been overwritten.
  $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');
}