function PathValidatorTest::testGetUrlIfValidWithFrontPageAndQueryAndFragments

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithFrontPageAndQueryAndFragments()
  2. 10 core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithFrontPageAndQueryAndFragments()
  3. 11.x core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithFrontPageAndQueryAndFragments()

Tests the getUrlIfValid() method with a front page + query + fragments.

@covers ::getUrlIfValid

File

core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php, line 411

Class

PathValidatorTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Path%21PathValidator.php/class/PathValidator/8.9.x" title="Provides a default path validator and access checker." class="local">\Drupal\Core\Path\PathValidator</a> @group Routing

Namespace

Drupal\Tests\Core\Path

Code

public function testGetUrlIfValidWithFrontPageAndQueryAndFragments() {
    $url = $this->pathValidator
        ->getUrlIfValid('<front>?hei=sen#berg');
    $this->assertEquals('<front>', $url->getRouteName());
    $this->assertEquals([
        'hei' => 'sen',
    ], $url->getOptions()['query']);
    $this->assertEquals('berg', $url->getOptions()['fragment']);
}

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