function geoipLanguageTestCase::addLanguage in GeoIP API 6
Same name and namespace in other branches
- 7 geoip_language/geoip_language.test \geoipLanguageTestCase::addLanguage()
Enable the specified language if it has not been already.
Parameters
string $language_code: The language code to enable.
1 call to geoipLanguageTestCase::addLanguage()
- geoipLanguageTestCase::setUp in geoip_language/
geoip_language.test - Implementation of setUp().
File
- geoip_language/
geoip_language.test, line 52 - Test suite for geoip_language.module
Class
- geoipLanguageTestCase
- @file Test suite for geoip_language.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 language was installed successfully.', array(
'%language' => $languages[$language_code]->name,
)));
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.0
$this
->drupalPost(NULL, array(
'enabled[' . $language_code . ']' => TRUE,
), t('Save configuration'));
$this
->assertRaw(t('Configuration saved.'), t('Language successfully enabled.'));
}
}