1 locale.test LocaleImportFunctionalTest::testAutomaticModuleTranslationImportLanguageEnable()

Test automatic import of a module's translation files.

File

core/modules/locale/tests/locale.test, line 880
Tests for locale.module.

Class

LocaleImportFunctionalTest
Functional tests for the import of translation files.

Code

function testAutomaticModuleTranslationImportLanguageEnable() {
  // Code for the language - manually set to match the test translation file.
  $langcode = 'xx';
  // The English name for the language.
  $name = $this->randomName(16);

  // Create a custom language.
  $edit = array(
    'predefined_langcode' => 'custom',
    'langcode' => $langcode,
    'name' => $name,
    'native' => $name,
    'direction' => '0',
  );
  $this->backdropPost('admin/config/regional/language/add', $edit, t('Add custom language'));

  // Ensure the translation file was automatically imported when language was
  // added.
  $this->assertText(t('One translation file imported.'), 'Language file automatically imported.');

  // Ensure strings were successfully imported.
  $search = array(
    'string' => 'lundi',
    'language' => $langcode,
    'translation' => 'translated',
  );
  $this->backdropPost('admin/config/regional/translate/translate', $search, t('Filter'));
  $this->assertNoText(t('No strings available.'), 'String successfully imported.');
}