function LocaleImportFunctionalTest::testEmptyMsgstr

Same name in other branches
  1. 9 core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::testEmptyMsgstr()
  2. 8.9.x core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::testEmptyMsgstr()
  3. 10 core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::testEmptyMsgstr()
  4. 11.x core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::testEmptyMsgstr()

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

File

modules/locale/locale.test, line 1108

Class

LocaleImportFunctionalTest
Functional tests for the import of translation files.

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,
    )), 'The translation file was successfully imported.');
    $this->assertIdentical(t('Operations', array(), array(
        'langcode' => $langcode,
    )), 'Műveletek', '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,
    )), '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, 'Search found the string.');
    $this->assertRaw($language_indicator, 'String is untranslated again.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.