diff --git a/entity_translation.module b/entity_translation.module index dd728f5..792a1fb 100644 --- a/entity_translation.module +++ b/entity_translation.module @@ -1904,7 +1904,7 @@ function entity_translation_languages($entity_type = NULL, $entity = NULL) { if (isset($entity) && $entity_type == 'node' && module_exists('i18n_node')) { // @todo Inherit i18n language settings. } - elseif (variable_get('entity_translation_languages_enabled', FALSE)) { + if (variable_get('entity_translation_languages_enabled', TRUE)) { $languages = language_list('enabled'); return $languages[1]; } diff --git a/tests/entity_translation.test b/tests/entity_translation.test index f440b4b..7e62cd5 100644 --- a/tests/entity_translation.test +++ b/tests/entity_translation.test @@ -133,6 +133,32 @@ class EntityTranslationTestCase extends DrupalWebTestCase { } /** + * Disable a language which is in the language list + * + * @param $langcode + * The code of the language to disable, which must exist. + */ + function disableLanguage($langcode) { + $edit = array( + 'enabled[' . $langcode . ']' => FALSE, + ); + $this->drupalPost('admin/config/regional/language', $edit, 'Save configuration'); + } + + /** + * Make a language the default language + * + * @param $langcode + * The langcode of the language to set as default + */ + function setDefaultLanguage($langcode) { + $edit = array( + 'site_default' => $langcode, + ); + $this->drupalPost('admin/config/regional/language', $edit, 'Save configuration'); + } + + /** * Install a specified language if it has not been already, otherwise make sure that the language is enabled. * * @param $langcode @@ -269,11 +295,34 @@ class EntityTranslationTranslationTestCase extends EntityTranslationTestCase { $this->login($this->getAdminUser()); $this->addLanguage('en'); $this->addLanguage('es'); + $this->addLanguage('fr'); + $this->disableLanguage('fr'); $this->configureContentType(); $this->login($this->getTranslatorUser()); } /** + * Test disabled languages. + * + * Make sure disabled languages are not accessible in the language list when + * creating and translating content. + */ + function testDisabledLanguages() { + $this->drupalGet('node/add/page'); + $this->assertNoRaw('value="fr"', 'French is not available because the language is disabled'); + $this->assertRaw('value="en"', 'English is available because the language is enabled'); + $this->assertRaw('value="es"', 'Spanish is available because the language is enabled'); + $this->login($this->getAdminUser()); + $this->addlanguage('hu'); + $this->setDefaultLanguage('hu'); + $this->disableLanguage('en'); + $this->login($this->getTranslatorUser()); + $this->drupalGet('node/add/page'); + $this->assertNoRaw('value="en"', 'English is no longer available because the language is disabled'); + $this->assertRaw('value="hu"', 'Hungarian, now default and enabled, is available.'); + } + + /** * Test if field based translation works. * * Enable field based translation for basic pages. Add a field with a