LocaleUrlRewritingTest::checkUrl

7 locale.test private LocaleUrlRewritingTest::checkUrl($language, $message1, $message2)
8 locale.test private LocaleUrlRewritingTest::checkUrl($language, $message1, $message2)

Check URL rewriting for the given language.

The test is performed with a fixed URL (the default front page) to simply check that language prefixes are not added to it and that the prefixed URL is actually not working.

File

modules/locale/locale.test, line 2571
Tests for locale.module.

Code

private function checkUrl($language, $message1, $message2) {
  $options = array('language' => $language);
  $base_path = trim(base_path(), '/');
  $rewritten_path = trim(str_replace(array('?q=', $base_path), '', url('node', $options)), '/');
  $segments = explode('/', $rewritten_path, 2);
  $prefix = $segments[0];
  $path = isset($segments[1]) ? $segments[1] : $prefix;
  // If the rewritten URL has not a language prefix we pick the right one from
  // the language object so we can always check the prefixed URL.
  if ($this->assertNotEqual($language->prefix, $prefix, $message1)) {
    $prefix = $language->prefix;
  }
  $this->drupalGet("$prefix/$path");
  $this->assertResponse(404, $message2);
}
Login or register to post comments