public function RedirectUnitTest::testLoadRedirectsBySource in Redirect 7
Same name and namespace in other branches
- 7.2 redirect.test \RedirectUnitTest::testLoadRedirectsBySource()
Test redirect_load_by_source().
File
- ./
redirect.test, line 135 - Unit tests for the redirect module.
Class
Code
public function testLoadRedirectsBySource() {
$redirects = array(
'source-path?param1=1¶m2=2' => 'redirect-path-1',
'source-path' => 'redirect-path-2',
'source-path?param1=1' => 'redirect-path-3',
);
// Add redirects.
foreach ($redirects as $source_path => $redirect_path) {
$this
->addRedirect($source_path, $redirect_path);
}
// Load redirects by source.
foreach ($redirects as $source_path => $redirect_path) {
$source_parsed = redirect_parse_url($source_path);
if (!isset($source_parsed['query'])) {
$source_parsed['query'] = array();
}
$redirect = redirect_load_by_source($source_parsed['url'], LANGUAGE_NONE, $source_parsed['query']);
$this
->assertEqual($redirect->redirect, $redirect_path, t('The redirect path %redirect equals expected result %result.', array(
'%redirect' => $redirect->redirect,
'%result' => $redirect_path,
)));
}
}