function PathValidatorTest::testGetUrlIfValidWithoutAccess

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

Tests the getUrlIfValid() method where there is no access.

@covers ::getUrlIfValid

File

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

Class

PathValidatorTest
@coversDefaultClass \Drupal\Core\Path\PathValidator @group Routing

Namespace

Drupal\Tests\Core\Path

Code

public function testGetUrlIfValidWithoutAccess() {
    $this->account
        ->expects($this->once())
        ->method('hasPermission')
        ->with('link to any page')
        ->willReturn(FALSE);
    $this->accessAwareRouter
        ->expects($this->once())
        ->method('match')
        ->with('/test-path')
        ->willThrowException(new AccessDeniedHttpException());
    $this->pathProcessor
        ->expects($this->once())
        ->method('processInbound')
        ->willReturnArgument(0);
    $url = $this->pathValidator
        ->getUrlIfValid('test-path');
    $this->assertFalse($url);
}

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