You are here

function ValidUrlTestCase::testInvalidAbsolute in Drupal 7

Test invalid absolute URLs.

File

modules/simpletest/tests/common.test, line 2412
Tests for common.inc functionality.

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