function TranslationModuleTestCase::add_language in SimpleTest 6
Install a the specified language if it has not been already. Otherwise make sure that the language is enabled.
Parameters
string $language_code The langauge code the check.:
1 call to TranslationModuleTestCase::add_language()
File
- tests/
translation_module.test, line 73
Class
Code
function add_language($language_code) {
// Check to make sure that language has not already been installed.
$this
->drupalGet('admin/settings/language');
if (strpos($this
->drupalGetContent(), 'enabled[' . $language_code . ']') === FALSE) {
// Doesn't have language installed so add it.
$edit = array();
$edit['langcode'] = $language_code;
$this
->drupalPost('admin/settings/language/add', $edit, 'Add language');
$languages = language_list('language', TRUE);
// make sure not using cached version
$this
->assertTrue(array_key_exists($language_code, $languages), 'Language was installed successfully.');
if (array_key_exists($language_code, $languages)) {
$this
->assertWantedRaw(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array(
'%language' => $languages[$language_code]->name,
'@locale-help' => url('admin/help/locale'),
)));
}
}
else {
// Ensure that it is enabled.
$this
->assertTrue(true, 'Language [' . $language_code . '] already installed.');
$this
->drupalPost(NULL, array(
'enabled[' . $language_code . ']' => TRUE,
), 'Save configuration');
$this
->assertWantedRaw(t('Configuration saved.'), 'Language successfully enabled.');
}
}