1 common.test CommonValidUrlUnitTestCase::testValidRelative()

Test valid relative URLs.

File

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

Class

CommonValidUrlUnitTestCase
Tests URL validation by valid_url().

Code

function testValidRelative() {
  $valid_relative_urls = array(
    'paren(the)sis',
    'index.html#pagetop',
    'index.php?q=node',
    'index.php?q=node&param=false',
    'login.php?do=login&style=%23#pagetop',
  );

  foreach (array('', '/') as $front) {
    foreach ($valid_relative_urls as $url) {
      $test_url = $front . $url;
      $valid_url = valid_url($test_url);
      $this->assertTrue($valid_url, format_string('@url is a valid url.', array('@url' => $test_url)));
    }
  }
}