public function BrowserTest::testGetAbsoluteUrl in Drupal 8
Test \Drupal\simpletest\WebTestBase::getAbsoluteUrl().
File
- core/
modules/ simpletest/ src/ Tests/ BrowserTest.php, line 42
Class
- BrowserTest
- Tests the internal browser of the testing framework.
Namespace
Drupal\simpletest\TestsCode
public function testGetAbsoluteUrl() {
$url = 'user/login';
$this
->drupalGet($url);
$absolute = Url::fromRoute('user.login', [], [
'absolute' => TRUE,
])
->toString();
$this
->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this
->assertEqual($this->url, $this
->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
$this
->drupalPostForm(NULL, [], t('Log in'));
$this
->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this
->assertEqual($this->url, $this
->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
$this
->clickLink('Create new account');
$absolute = Url::fromRoute('user.register', [], [
'absolute' => TRUE,
])
->toString();
$this
->assertEqual($absolute, $this->url, 'Passed and requested URL are equal.');
$this
->assertEqual($this->url, $this
->getAbsoluteUrl($this->url), 'Requested and returned absolute URL are equal.');
}