function UrlTest::testGetUriForProtocolRelativeUrl

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

@legacy-covers ::getUri @legacy-covers ::isExternal

File

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

Class

UrlTest
Tests Drupal\Core\Url.

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.