function LocaleImportFunctionalTest::testEmptyMsgstr

Same name in other branches
  1. 7.x modules/locale/locale.test \LocaleImportFunctionalTest::testEmptyMsgstr()
  2. 9 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

core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php, line 270

Class

LocaleImportFunctionalTest
Tests the import of locale files.

Namespace

Drupal\Tests\locale\Functional

Code

public function testEmptyMsgstr() {
    $langcode = 'hu';
    // Try importing a .po file.
    $this->importPoFile($this->getPoFileWithMsgstr(), [
        'langcode' => $langcode,
    ]);
    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', [
        '%number' => 1,
        '%update' => 0,
        '%delete' => 0,
    ]), 'The translation file was successfully imported.');
    $this->assertIdentical((string) t('Operations', [], [
        'langcode' => $langcode,
    ]), 'Műveletek', 'String imported and translated.');
    // Try importing a .po file.
    $this->importPoFile($this->getPoFileWithEmptyMsgstr(), [
        'langcode' => $langcode,
        'overwrite_options[not_customized]' => TRUE,
    ]);
    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', [
        '%number' => 0,
        '%update' => 0,
        '%delete' => 1,
    ]), 'The translation file was successfully imported.');
    $str = "Operations";
    $search = [
        'string' => $str,
        'langcode' => $langcode,
        'translation' => 'untranslated',
    ];
    $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
    $this->assertText($str, 'Search found the string as untranslated.');
}

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