function LocaleImportFunctionalTest::testAutomaticModuleTranslationImportLanguageEnable
7.x locale.test | LocaleImportFunctionalTest::testAutomaticModuleTranslationImportLanguageEnable() |
Test automatic import of a module's translation files when a language is enabled.
File
- drupal-7.x/
modules/ locale/ locale.test, line 1012 - 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.');
}