function PathValidatorTest::testGetUrlIfValidWithoutAccessCheck

Same name in this branch
  1. 10 core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php \Drupal\KernelTests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccessCheck()
Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php \Drupal\KernelTests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccessCheck()
  2. 9 core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccessCheck()
  3. 8.9.x core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php \Drupal\KernelTests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccessCheck()
  4. 8.9.x core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccessCheck()
  5. 11.x core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php \Drupal\KernelTests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccessCheck()
  6. 11.x core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccessCheck()

Tests the getUrlIfValidWithoutAccessCheck() method.

@covers ::getUrlIfValidWithoutAccessCheck
@covers ::getPathAttributes

File

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

Class

PathValidatorTest
@coversDefaultClass \Drupal\Core\Path\PathValidator[[api-linebreak]] @group Routing

Namespace

Drupal\Tests\Core\Path

Code

public function testGetUrlIfValidWithoutAccessCheck() : void {
  $this->account
    ->expects($this->never())
    ->method('hasPermission')
    ->with('link to any page');
  $this->accessAwareRouter
    ->expects($this->never())
    ->method('match');
  $this->accessUnawareRouter
    ->expects($this->once())
    ->method('match')
    ->with('/test-path')
    ->willReturn([
    RouteObjectInterface::ROUTE_NAME => 'test_route',
    '_raw_variables' => new InputBag([
      'key' => 'value',
    ]),
  ]);
  $this->pathProcessor
    ->expects($this->once())
    ->method('processInbound')
    ->willReturnArgument(0);
  $url = $this->pathValidator
    ->getUrlIfValidWithoutAccessCheck('test-path');
  $this->assertInstanceOf('Drupal\\Core\\Url', $url);
  $this->assertEquals('test_route', $url->getRouteName());
  $this->assertEquals([
    'key' => 'value',
  ], $url->getRouteParameters());
}

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