function BrowserTest::testGetAbsoluteUrl

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\Tests

Code

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.');
}

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