function ValidUrlTestCase::testInvalidAbsolute

Test invalid absolute URLs.

File

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

Class

ValidUrlTestCase
Test for valid_url().

Code

function testInvalidAbsolute() {
    $url_schemes = array(
        'http',
        'https',
        'ftp',
    );
    $invalid_ablosule_urls = array(
        '',
        'ex!ample.com',
        'ex%ample.com',
    );
    foreach ($url_schemes as $scheme) {
        foreach ($invalid_ablosule_urls as $url) {
            $test_url = $scheme . '://' . $url;
            $valid_url = valid_url($test_url, TRUE);
            $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.