You are here

public function BrowserTest::testGetAbsoluteUrl in SimpleTest 8.3

Test \Drupal\simpletest\WebTestBase::getAbsoluteUrl().

File

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