function UrlTest::testGetUriForProtocolRelativeUrl

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testGetUriForProtocolRelativeUrl()
  2. 8.9.x core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testGetUriForProtocolRelativeUrl()
  3. 11.x core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testGetUriForProtocolRelativeUrl()

Tests the getUri() and isExternal() methods for protocol-relative URLs.

@covers ::getUri @covers ::isExternal

File

core/tests/Drupal/Tests/Core/UrlTest.php, line 316

Class

UrlTest
@coversDefaultClass \Drupal\Core\Url @group UrlTest

Namespace

Drupal\Tests\Core

Code

public function testGetUriForProtocolRelativeUrl() : void {
    $url = Url::fromUri('//example.com/test');
    $this->assertEquals('//example.com/test', $url->getUri());
    $this->assertTrue($url->isExternal());
}

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