diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-01-22 03:18:30 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-01-22 03:18:30 +0000 |
commit | afc9df994a10a2af320f21fe87f47f10315dd28b (patch) | |
tree | d58d730b096d406e74bf12c84c22d74c281c536b /modules/locale | |
parent | b4c737a2a5ed9bf9905c91107f94e42df36f2c44 (diff) | |
download | brdo-afc9df994a10a2af320f21fe87f47f10315dd28b.tar.gz brdo-afc9df994a10a2af320f21fe87f47f10315dd28b.tar.bz2 |
#220559 by eMPee584 and Damien Tournoud: Fix bug in language switcher block that makes all languages active (with tests)
Diffstat (limited to 'modules/locale')
-rw-r--r-- | modules/locale/locale.test | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/modules/locale/locale.test b/modules/locale/locale.test index 4936d14eb..086a36ec2 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -292,3 +292,79 @@ msgstr "supprimer<script>alert('xss');</script>" EOF; } } + +/** + * Functional tests for the language switching feature. + */ +class LanguageSwitchingFunctionalTest extends DrupalWebTestCase { + + function getInfo() { + return array( + 'name' => t('Language switching'), + 'description' => t('Tests for the language switching feature.'), + 'group' => t('Locale'), + ); + } + + function setUp() { + parent::setUp('locale'); + + // Create and login user + $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer languages', 'translate interface', 'access administration pages')); + $this->drupalLogin($admin_user); + } + + function testLanguageBlock() { + // Enable the language switching block. + $edit = array( + 'locale_language-switcher[region]' => 'left', + ); + $this->drupalPost('admin/build/block', $edit, t('Save blocks')); + + // Add language. + $edit = array( + 'langcode' => 'fr', + ); + $this->drupalPost('admin/settings/language/add', $edit, t('Add language')); + + // Set language negotiation. + $edit = array( + 'language_negotiation' => LANGUAGE_NEGOTIATION_PATH_DEFAULT, + ); + $this->drupalPost('admin/settings/language/configure', $edit, t('Save settings')); + + // Assert that the language switching block is displayed on the frontpage. + $this->drupalGet(''); + $this->assertText(t('Languages')); + + // Assert that only the current language is marked as active. + list($language_switcher) = $this->xpath('//div[@id="block-locale-language-switcher"]'); + $links = array( + 'active' => array(), + 'inactive' => array(), + ); + $anchors = array( + 'active' => array(), + 'inactive' => array(), + ); + foreach ($language_switcher->div->ul->li as $link) { + $classes = explode(" ", (string) $link['class']); + list($language) = array_intersect($classes, array('en', 'fr')); + if (in_array('active', $classes)) { + $links['active'][] = $language; + } + else { + $links['inactive'][] = $language; + } + $anchor_classes = explode(" ", (string) $link->a['class']); + if (in_array('active', $anchor_classes)) { + $anchors['active'][] = $language; + } + else { + $anchors['inactive'][] = $language; + } + } + $this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), t('Only the current language list item is marked as active on the language switcher block')); + $this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), t('Only the current language anchor is marked as active on the language switcher block')); + } +} |