function LocaleImportFunctionalTest::testEmptyMsgstr

Same name and namespace 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. 8.9.x 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()

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

File

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

Class

LocaleImportFunctionalTest
Tests the import of locale files.

Namespace

Drupal\Tests\locale\Functional

Code

public function testEmptyMsgstr() : void {
  $langcode = 'hu';
  // Try importing a .po file.
  $this->importPoFile($this->getPoFileWithMsgstr(), [
    'langcode' => $langcode,
  ]);
  $this->assertSession()
    ->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
  $this->assertSame('Műveletek', (string) t('Operations', [], [
    'langcode' => $langcode,
  ]), 'String imported and translated.');
  // Try importing a .po file.
  $this->importPoFile($this->getPoFileWithEmptyMsgstr(), [
    'langcode' => $langcode,
    'overwrite_options[not_customized]' => TRUE,
  ]);
  $this->assertSession()
    ->pageTextContains("One translation file imported. 0 translations were added, 0 translations were updated and 1 translations were removed.");
  $str = "Operations";
  $search = [
    'string' => $str,
    'langcode' => $langcode,
    'translation' => 'untranslated',
  ];
  // Check that search finds the string as untranslated.
  $this->drupalGet('admin/config/regional/translate');
  $this->submitForm($search, 'Filter');
  $this->assertSession()
    ->pageTextContains($str);
}

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