function ValidUrlTestCase::testInvalidRelative

Test invalid relative URLs.

File

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

Class

ValidUrlTestCase
Test for valid_url().

Code

function testInvalidRelative() {
    $invalid_relative_urls = array(
        'ex^mple',
        'example<>',
        'ex%ample',
    );
    foreach (array(
        '',
        '/',
    ) as $front) {
        foreach ($invalid_relative_urls as $url) {
            $test_url = $front . $url;
            $valid_url = valid_url($test_url);
            $this->assertFALSE($valid_url, format_string('@url is NOT 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.