function ValidUrlTestCase::testValidRelative

Test valid relative URLs.

File

modules/simpletest/tests/common.test, line 2564

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&param=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,
            )));
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.