public function L10nUpdateTest::testEnableCustomLanguage in Localization update 7.2
Tests automatic translation import when a custom langauge is enabled.
File
- tests/
L10nUpdateTest.test, line 394 - Contains L10nUpdateTest.
Class
- L10nUpdateTest
- Tests for update translations.
Code
public function testEnableCustomLanguage() {
// Make the hidden test modules look like a normal custom module.
variable_set('l10n_update_test_system_info_alter', TRUE);
// Enable a module.
$edit = array(
'modules[Testing][l10n_update_test_translate][enable]' => '1',
);
$this
->drupalPost('admin/modules', $edit, t('Save configuration'));
// Create and enable a custom language with language code 'xx' and a random
// name.
$langcode = 'xx';
$name = $this
->randomName(16);
$edit = array(
'langcode' => $langcode,
'name' => $name,
'native' => $name,
'prefix' => $langcode,
'direction' => '0',
);
$this
->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
drupal_static_reset('language_list');
$languages = language_list();
$this
->assertTrue(isset($languages[$langcode]), format_string('Language %langcode added.', array(
'%langcode' => $langcode,
)));
// Ensure the translation file is automatically imported when the language
// was added.
$this
->assertText(t('One translation file imported.'), 'Language file automatically imported.');
$this
->assertText(t('One translation string was skipped because of disallowed or malformed HTML'), 'Language file automatically imported.');
// Ensure the strings were successfully imported.
$search = array(
'string' => 'lundi',
'language' => $langcode,
'translation' => 'translated',
);
$this
->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this
->assertNoText(t('No strings available.'), 'String successfully imported.');
// Ensure the multiline string was imported.
$search = array(
'string' => 'Source string for multiline translation',
'language' => $langcode,
'translation' => 'all',
);
$this
->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this
->assertText('Source string for multiline translation', 'String successfully imported.');
// Ensure 'Allowed HTML source string' was imported but the translation for
// 'Another allowed HTML source string' was not because it contains invalid
// HTML.
$search = array(
'string' => 'HTML source string',
'language' => $langcode,
'translation' => 'translated',
);
$this
->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// $this->assertText('Allowed HTML source string', 'String successfully imported.'); $this->assertNoText('Another allowed HTML source string', 'String with disallowed translation not imported.');
}