public function PathValidatorTest::testGetUrlIfValidWithoutAccess in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php \Drupal\Tests\Core\Path\PathValidatorTest::testGetUrlIfValidWithoutAccess()
Tests the getUrlIfValid() method where there is no access.
File
- core/tests/ Drupal/ Tests/ Core/ Path/ PathValidatorTest.php, line 315 
- Contains \Drupal\Tests\Core\Path\PathValidatorTest.
Class
- PathValidatorTest
- @coversDefaultClass \Drupal\Core\Path\PathValidator @group Routing
Namespace
Drupal\Tests\Core\PathCode
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);
}