diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-26 22:37:30 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-26 22:37:30 -0700 |
commit | 796df0355792f5d303ae01bc2ddef61b589bc442 (patch) | |
tree | eb65220077c4baceba153b2dbcbb55a622692095 /modules/locale | |
parent | 0932803a2c0a61924209dfe277dec32bced63c0c (diff) | |
download | brdo-796df0355792f5d303ae01bc2ddef61b589bc442.tar.gz brdo-796df0355792f5d303ae01bc2ddef61b589bc442.tar.bz2 |
Issue #1250800 by attiks, Jelle_S, dawehner, xjm, Gábor Hojtsy: Fixed Language domain should work regardless of ports or protocols.
Diffstat (limited to 'modules/locale')
-rw-r--r-- | modules/locale/locale.test | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/locale/locale.test b/modules/locale/locale.test index 0a8ed42f7..40502a29a 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -2449,6 +2449,56 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase { $fields = $this->xpath('//div[@id="site-name"]//a[@rel="home" and @href=:url]//span', $args); $this->assertTrue($fields[0] == 'Drupal', t('URLs are rewritten using the browser language.')); } + + /** + * Tests url() when separate domains are used for multiple languages. + */ + function testLanguageDomain() { + // Add the Italian language, without protocol. + $langcode = 'it'; + locale_add_language($langcode, 'Italian', 'Italian', LANGUAGE_LTR, 'it.example.com', '', TRUE, FALSE); + + // Add the French language, with protocol. + $langcode = 'fr'; + locale_add_language($langcode, 'French', 'French', LANGUAGE_LTR, 'http://fr.example.com', '', TRUE, FALSE); + + // Enable language URL detection. + $negotiation = array_flip(array(LOCALE_LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT)); + language_negotiation_set(LANGUAGE_TYPE_INTERFACE, $negotiation); + + variable_set('locale_language_negotiation_url_part', 1); + + global $is_https; + $languages = language_list(); + + foreach (array('it', 'fr') as $langcode) { + // Build the link we're going to test based on the clean url setting. + $link = (!empty($GLOBALS['conf']['clean_url'])) ? $langcode . '.example.com/admin' : $langcode . '.example.com/?q=admin'; + + // Test URL in another language. + // Base path gives problems on the testbot, so $correct_link is hard-coded. + // @see UrlAlterFunctionalTest::assertUrlOutboundAlter (path.test). + $url = url('admin', array('language' => $languages[$langcode])); + $url_scheme = ($is_https) ? 'https://' : 'http://'; + $correct_link = $url_scheme . $link; + $this->assertTrue($url == $correct_link, t('The url() function returns the right url (@url) in accordance with the chosen language', array('@url' => $url . " == " . $correct_link))); + + // Test https via options. + variable_set('https', TRUE); + $url = url('admin', array('https' => TRUE, 'language' => $languages[$langcode])); + $correct_link = 'https://' . $link; + $this->assertTrue($url == $correct_link, t('The url() function returns the right https url (via options) (@url) in accordance with the chosen language', array('@url' => $url . " == " . $correct_link))); + variable_set('https', FALSE); + + // Test https via current url scheme. + $temp_https = $is_https; + $is_https = TRUE; + $url = url('admin', array('language' => $languages[$langcode])); + $correct_link = 'https://' . $link; + $this->assertTrue($url == $correct_link, t('The url() function returns the right url (via current url scheme) (@url) in accordance with the chosen language', array('@url' => $url . " == " . $correct_link))); + $is_https = $temp_https; + } + } } /** |