1 common.test CommonValidUrlUnitTestCase::testInvalidAbsolute()

Test invalid absolute URLs.

File

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

Class

CommonValidUrlUnitTestCase
Tests URL validation by 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)));
    }
  }
}