function i18nAccessTestCase::addLanguage in Translation Access 6
Same name and namespace in other branches
- 7 i18n_access.test \i18nAccessTestCase::addLanguage()
Enable the specified language if it has not been already.
Parameters
string $language_code: The language code to enable.
1 call to i18nAccessTestCase::addLanguage()
- i18nAccessTestCase::setUp in ./
i18n_access.test - Implementation of setUp().
File
- ./
i18n_access.test, line 48 - Test suite for i18n_access.module
Class
- i18nAccessTestCase
- @file Test suite for i18n_access.module
Code
function addLanguage($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, t('Add language'));
$languages = language_list('language', TRUE);
// Make sure not using cached version.
$this
->assertTrue(array_key_exists($language_code, $languages), t('Language was installed successfully.'));
if (array_key_exists($language_code, $languages)) {
$this
->assertRaw(t('The language %language has been created and can now be used.', array(
'%language' => $languages[$language_code]->name,
)), t('Language has been created.'));
}
}
else {
// Ensure that it is enabled.
$this
->drupalPost(NULL, array(
'enabled[' . $language_code . ']' => TRUE,
), t('Save configuration'));
$this
->assertRaw(t('Configuration saved.'), t('Language successfully enabled.'));
}
}