function EntityTranslationTestCase::addLanguage in Entity Translation 7
Install a specified language if it has not been already, otherwise make sure that the language is enabled.
Parameters
$langcode: The language code to check.
8 calls to EntityTranslationTestCase::addLanguage()
- EntityTranslationCommentTestCase::setUp in tests/
entity_translation.test - Sets up a Drupal site for running functional and integration tests.
- EntityTranslationContentTranslationTestCase::setUp in tests/
entity_translation.test - Sets up a Drupal site for running functional and integration tests.
- EntityTranslationHookTestCase::setUp in tests/
entity_translation.test - Sets up a Drupal site for running functional and integration tests.
- EntityTranslationIntegrationTestCase::setUp in tests/
entity_translation.test - Sets up a Drupal site for running functional and integration tests.
- EntityTranslationMenuTranslationTestCase::setUp in entity_translation_i18n_menu/
entity_translation_i18n_menu.test - Sets up a Drupal site for running functional and integration tests.
File
- tests/
entity_translation.test, line 158 - Tests for Entity translation module.
Class
- EntityTranslationTestCase
- Base class for entity translation module tests.
Code
function addLanguage($langcode) {
// Check to make sure that language has not already been installed.
$this
->drupalGet('admin/config/regional/language');
if (strpos($this
->drupalGetContent(), 'enabled[' . $langcode . ']') === FALSE) {
// Doesn't have language installed so add it.
$edit = array();
$edit['langcode'] = $langcode;
$this
->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Make sure we are not using a stale list.
drupal_static_reset('language_list');
$languages = language_list('language');
$this
->assertTrue(array_key_exists($langcode, $languages), t('Language was installed successfully.'));
if (array_key_exists($langcode, $languages)) {
$this
->assertRaw(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[$langcode]->name,
'@locale-help' => url('admin/help/locale'),
)), t('Language has been created.'));
}
}
elseif ($this
->xpath('//input[@type="checkbox" and @name=:name and @checked="checked"]', array(
':name' => 'enabled[' . $langcode . ']',
))) {
// It is installed and enabled. No need to do anything.
$this
->assertTrue(TRUE, 'Language [' . $langcode . '] already installed and enabled.');
}
else {
// It is installed but not enabled. Enable it.
$this
->assertTrue(TRUE, 'Language [' . $langcode . '] already installed.');
$this
->drupalPost(NULL, array(
'enabled[' . $langcode . ']' => TRUE,
), t('Save configuration'));
$this
->assertRaw(t('Configuration saved.'), t('Language successfully enabled.'));
}
}