function ValidUrlUnitTest::testInvalidRelative

Tests invalid relative URLs.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/ValidUrlUnitTest.php, line 103
Definition of Drupal\system\Tests\Common\ValidUrlUnitTest.

Class

ValidUrlUnitTest
Tests URL validation by valid_url().

Namespace

Drupal\system\Tests\Common

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