function UrlHelperTest::testExternalIsLocal

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testExternalIsLocal()
  2. 10 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testExternalIsLocal()
  3. 9 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testExternalIsLocal()
  4. 8.9.x core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testExternalIsLocal()

Tests detecting external URLs that point to local resources.

Attributes

#[DataProvider('providerTestExternalIsLocal')]

Parameters

string $url: The external URL to test.

string $base_url: The base URL.

bool $expected: TRUE if an external URL points to this installation as determined by the base URL.

File

core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php, line 632

Class

UrlHelperTest
Tests Drupal\Component\Utility\UrlHelper.

Namespace

Drupal\Tests\Component\Utility

Code

public function testExternalIsLocal($url, $base_url, $expected) : void {
  $this->assertSame($expected, UrlHelper::externalIsLocal($url, $base_url));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.