You are here

protected function UrlIsExternalUnitTest::examples in Drupal 7

Provides data for testUrlIsExternal().

Return value

array An array of test data, keyed by a path, with the expected value where TRUE is external, and FALSE is not external.

1 call to UrlIsExternalUnitTest::examples()
UrlIsExternalUnitTest::testUrlIsExternal in modules/simpletest/tests/common.test
Tests if each URL is external or not.

File

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

Class

UrlIsExternalUnitTest
Tests url_is_external().

Code

protected function examples() {
  return array(
    // Simple external URLs.
    'http://example.com' => TRUE,
    'https://example.com' => TRUE,
    'http://drupal.org/foo/bar?foo=bar&bar=baz&baz#foo' => TRUE,
    '//drupal.org' => TRUE,
    // Some browsers ignore or strip leading control characters.
    "\0//www.example.com" => TRUE,
    "\10//www.example.com" => TRUE,
    "\37//www.example.com" => TRUE,
    "\n//www.example.com" => TRUE,
    // JSON supports decoding directly from UTF-8 code points.
    json_decode('"\\u00AD"') . "//www.example.com" => TRUE,
    json_decode('"\\u200E"') . "//www.example.com" => TRUE,
    json_decode('"\\uE0020"') . "//www.example.com" => TRUE,
    json_decode('"\\uE000"') . "//www.example.com" => TRUE,
    // Backslashes should be normalized to forward.
    '\\\\example.com' => TRUE,
    // Local URLs.
    'node' => FALSE,
    '/system/ajax' => FALSE,
    '?q=foo:bar' => FALSE,
    'node/edit:me' => FALSE,
    '/drupal.org' => FALSE,
    '<front>' => FALSE,
  );
}