LocaleImportFunctionalTest::testAutomaticModuleTranslationImportLanguageEnable

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

Test automatic import of a module's translation files when a language is enabled.

File

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

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);
  // The native name for the language.
  $native = $this->randomName(16);
  // The domain prefix.
  $prefix = $langcode;

  // Create a custom language.
  $edit = array(
    'langcode' => $langcode, 
    'name' => $name, 
    'native' => $native, 
    'prefix' => $prefix, 
    'direction' => '0',
  );
  $this->drupalPost('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 for the enabled modules.'), t('Language file automatically imported.'));

  // Ensure strings were successfully imported.
  $search = array(
    'string' => 'lundi', 
    'language' => $langcode, 
    'translation' => 'translated', 
    'group' => 'all',
  );
  $this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
  $this->assertNoText(t('No strings available.'), t('String successfully imported.'));
}
Login or register to post comments