You are here

public function L10nUpdateTest::testUpdateImportModeNonCustomized in Localization update 7.2

Tests translation import and only overwrite non-customized translations.

Test conditions:

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

File

tests/L10nUpdateTest.test, line 247
Contains L10nUpdateTest.

Class

L10nUpdateTest
Tests for update translations.

Code

public function testUpdateImportModeNonCustomized() {

  // Build the test environment.
  $this
    ->setTranslationFiles();
  $this
    ->setCurrentTranslations();
  variable_set('l10n_update_default_filename', '%project-%release.%language._po');

  // Set the test conditions.
  $edit = array(
    'l10n_update_check_mode' => L10N_UPDATE_USE_SOURCE_REMOTE_AND_LOCAL,
    'l10n_update_import_mode' => L10N_UPDATE_OVERWRITE_NON_CUSTOMIZED,
  );
  $this
    ->drupalPost('admin/config/regional/language/update', $edit, t('Save configuration'));

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

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