function AccessAwareRouterTest::testCheckAccessResultWithReason
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php \Drupal\Tests\Core\Routing\AccessAwareRouterTest::testCheckAccessResultWithReason()
- 10 core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php \Drupal\Tests\Core\Routing\AccessAwareRouterTest::testCheckAccessResultWithReason()
- 11.x core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php \Drupal\Tests\Core\Routing\AccessAwareRouterTest::testCheckAccessResultWithReason()
Tests the matchRequest() function for access denied with reason message.
File
-
core/
tests/ Drupal/ Tests/ Core/ Routing/ AccessAwareRouterTest.php, line 111
Class
- AccessAwareRouterTest
- @coversDefaultClass \Drupal\Core\Routing\AccessAwareRouter @group Routing
Namespace
Drupal\Tests\Core\RoutingCode
public function testCheckAccessResultWithReason() {
$this->setupRouter();
$request = new Request();
$reason = $this->getRandomGenerator()
->string();
$access_result = AccessResult::forbidden($reason);
$this->accessManager
->expects($this->once())
->method('checkRequest')
->with($request)
->willReturn($access_result);
$this->expectException(AccessDeniedHttpException::class);
$this->expectExceptionMessage($reason);
$this->accessAwareRouter
->matchRequest($request);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.