function ValidUrlTestCase::testValidRelative in Drupal 7
Test valid relative URLs.
File
- modules/
simpletest/ tests/ common.test, line 2432 - Tests for common.inc functionality.
Class
- ValidUrlTestCase
- Test for valid_url().
Code
function testValidRelative() {
$valid_relative_urls = array(
'paren(the)sis',
'index.html#pagetop',
'index.php?q=node',
'index.php?q=node¶m=false',
'login.php?do=login&style=%23#pagetop',
);
foreach (array(
'',
'/',
) as $front) {
foreach ($valid_relative_urls as $url) {
$test_url = $front . $url;
$valid_url = valid_url($test_url);
$this
->assertTrue($valid_url, format_string('@url is a valid url.', array(
'@url' => $test_url,
)));
}
}
}