1 common.test CommonValidUrlUnitTestCase::testInvalidAbsolute()

Test invalid absolute URLs.

File

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

Class

CommonValidUrlUnitTestCase
Tests URL validation by valid_url().

Code

function testInvalidAbsolute() {
  $url_schemes = array('http', 'https', 'ftp');
  $invalid_absolute_urls = array(
    // cspell:disable
    '',
    'ex!ample.com',
    'ex%ample.com',
    // cspell:enable
  );

  foreach ($url_schemes as $scheme) {
    foreach ($invalid_absolute_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)));
    }
  }
}