function LocaleImportFunctionalTest::testAutomaticModuleTranslationImportLanguageEnable in Drupal 7
Test automatic import of a module's translation files when a language is enabled.
File
- modules/
locale/ locale.test, line 1022 - 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);
// 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.'), '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.'), 'String successfully imported.');
}