You are here

public function AccessAwareRouterTest::testMatchRequestDenied in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php \Drupal\Tests\Core\Routing\AccessAwareRouterTest::testMatchRequestDenied()

Tests the matchRequest() function for access denied.

@expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException

File

core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php, line 97
Contains \Drupal\Tests\Core\Routing\AccessAwareRouterTest.

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);
  $parameters = $this->router
    ->matchRequest($request);
  $expected = [
    AccessAwareRouterInterface::ACCESS_RESULT => $access_result,
  ];
  $this
    ->assertSame($expected, $request->attributes
    ->all());
  $this
    ->assertSame($expected, $parameters);
}