function RouterTest::testUrlGeneratorFront

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testUrlGeneratorFront()
  2. 10 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testUrlGeneratorFront()
  3. 11.x core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testUrlGeneratorFront()

Checks the generate method on the URL generator using the front router.

File

core/modules/system/tests/src/Functional/Routing/RouterTest.php, line 235

Class

RouterTest
Functional class for the full integrated routing system.

Namespace

Drupal\Tests\system\Functional\Routing

Code

public function testUrlGeneratorFront() {
    $front_url = Url::fromRoute('<front>', [], [
        'absolute' => TRUE,
    ]);
    // Compare to the site base URL.
    $base_url = Url::fromUri('base:/', [
        'absolute' => TRUE,
    ]);
    $this->assertSame($base_url->toString(), $front_url->toString());
}

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