You are here

public function UrlHelperTest::providerTestExternalIsLocal in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::providerTestExternalIsLocal()

Provider for local external url detection.

See also

\Drupal\Tests\Component\Utility\UrlHelperTest::testExternalIsLocal()

File

core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php, line 506
Contains \Drupal\Tests\Component\Utility\UrlHelperTest.

Class

UrlHelperTest
@group Utility

Namespace

Drupal\Tests\Component\Utility

Code

public function providerTestExternalIsLocal() {
  return array(
    // Different mixes of trailing slash.
    array(
      'http://example.com',
      'http://example.com',
      TRUE,
    ),
    array(
      'http://example.com/',
      'http://example.com',
      TRUE,
    ),
    array(
      'http://example.com',
      'http://example.com/',
      TRUE,
    ),
    array(
      'http://example.com/',
      'http://example.com/',
      TRUE,
    ),
    // Sub directory of site.
    array(
      'http://example.com/foo',
      'http://example.com/',
      TRUE,
    ),
    array(
      'http://example.com/foo/bar',
      'http://example.com/foo',
      TRUE,
    ),
    array(
      'http://example.com/foo/bar',
      'http://example.com/foo/',
      TRUE,
    ),
    // Different sub-domain.
    array(
      'http://example.com',
      'http://www.example.com/',
      FALSE,
    ),
    array(
      'http://example.com/',
      'http://www.example.com/',
      FALSE,
    ),
    array(
      'http://example.com/foo',
      'http://www.example.com/',
      FALSE,
    ),
    // Different TLD.
    array(
      'http://example.com',
      'http://example.ca',
      FALSE,
    ),
    array(
      'http://example.com',
      'http://example.ca/',
      FALSE,
    ),
    array(
      'http://example.com/',
      'http://example.ca/',
      FALSE,
    ),
    array(
      'http://example.com/foo',
      'http://example.ca',
      FALSE,
    ),
    array(
      'http://example.com/foo',
      'http://example.ca/',
      FALSE,
    ),
    // Different site path.
    array(
      'http://example.com/foo',
      'http://example.com/bar',
      FALSE,
    ),
    array(
      'http://example.com',
      'http://example.com/bar',
      FALSE,
    ),
    array(
      'http://example.com/bar',
      'http://example.com/bar/',
      FALSE,
    ),
  );
}