function geoipLanguageTestCase::testDefaultLanguageNegotiation in GeoIP API 7
Same name and namespace in other branches
- 6 geoip_language/geoip_language.test \geoipLanguageTestCase::testDefaultLanguageNegotiation()
File
- geoip_language/
geoip_language.test, line 94 - Test suite for geoip_language.module
Class
- geoipLanguageTestCase
- @file Test suite for geoip_language.module
Code
function testDefaultLanguageNegotiation() {
global $base_url, $base_path;
$languages = language_list('language', TRUE);
// US ip address, should map to en language and force a redirect. Not using
// url() or any of its derivatives, so as not to taint this url.
$this
->drupalGet($base_url . $base_path . 'node?geoip_debug=140.211.166.6');
$url = url('node', array(
'absolute' => TRUE,
'language' => $languages['en'],
));
$this
->assertEqual($this
->getUrl(), $url, t('Redirect to default language (%url).', array(
'%url' => $this
->getUrl(),
)));
// Browse directly to a french page. No redirect should happen.
$this
->drupalGet('node', array(
'language' => $languages['fr'],
));
$url = url('node', array(
'absolute' => TRUE,
'language' => $languages['fr'],
));
$this
->assertEqual($this
->getUrl(), $url, t('No redirect for non-default language (%url).', array(
'%url' => $this
->getUrl(),
)));
// Now french should be in the session. Browsing directly to a page without
// a prefix should redirect me to the french version.
$this
->drupalGet($base_url . $base_path . 'node');
$url = url('node', array(
'absolute' => TRUE,
'language' => $languages['fr'],
));
$this
->assertEqual($this
->getUrl(), $url, t('Redirect to the language stored in the session (%url).', array(
'%url' => $this
->getUrl(),
)));
// Now just for good measure make sure that nothing weird happens when
// browsing directly to the a page with the default langauge's prefix.
$this
->drupalGet('node', array(
'language' => $languages['en'],
));
$url = url('node', array(
'absolute' => TRUE,
'language' => $languages['en'],
));
$this
->assertEqual($this
->getUrl(), $url, t('No redirect for default language prefix (%url).', array(
'%url' => $this
->getUrl(),
)));
}