function AccessAwareRouterTest::testMatchRequestDenied

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php \Drupal\Tests\Core\Routing\AccessAwareRouterTest::testMatchRequestDenied()
  2. 10 core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php \Drupal\Tests\Core\Routing\AccessAwareRouterTest::testMatchRequestDenied()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php \Drupal\Tests\Core\Routing\AccessAwareRouterTest::testMatchRequestDenied()

Tests the matchRequest() function for access denied.

File

core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php, line 96

Class

AccessAwareRouterTest
@coversDefaultClass \Drupal\Core\Routing\AccessAwareRouter @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testMatchRequestDenied() {
    $this->setupRouter();
    $request = new Request();
    $access_result = AccessResult::forbidden();
    $this->accessManager
        ->expects($this->once())
        ->method('checkRequest')
        ->with($request)
        ->willReturn($access_result);
    $this->expectException(AccessDeniedHttpException::class);
    $this->accessAwareRouter
        ->matchRequest($request);
}

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