LocaleImportFunctionalTest::testEmptyMsgstr

7 locale.test LocaleImportFunctionalTest::testEmptyMsgstr()
8 locale.test LocaleImportFunctionalTest::testEmptyMsgstr()

Test empty msgstr at end of .po file see #611786.

File

modules/locale/locale.test, line 1022
Tests for locale.module.

Code

function testEmptyMsgstr() {
  $langcode = 'hu';

  // Try importing a .po file.
  $this->importPoFile($this->getPoFileWithMsgstr(), array(
    'langcode' => $langcode,
  ));

  $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
  $this->assertIdentical(t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', t('String imported and translated.'));

  // Try importing a .po file.
  $this->importPoFile($this->getPoFileWithEmptyMsgstr(), array(
    'langcode' => $langcode, 
    'mode' => 0,
  ));
  $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 0, '%update' => 0, '%delete' => 1)), t('The translation file was successfully imported.'));
  // This is the language indicator on the translation search screen for
  // untranslated strings. Copied straight from locale.inc.
  $language_indicator = "<em class=\"locale-untranslated\">$langcode</em> ";
  $str = "Operations";
  $search = array(
    'string' => $str, 
    'language' => 'all', 
    'translation' => 'all', 
    'group' => 'all',
  );
  $this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
  // assertText() seems to remove the input field where $str always could be
  // found, so this is not a false assert.
  $this->assertText($str, t('Search found the string.'));
  $this->assertRaw($language_indicator, t('String is untranslated again.'));
}
Login or register to post comments