function AccessAwareRouterTest::testMatchRequestAllowed

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

Tests the matchRequest() function for access allowed.

File

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

Class

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

Namespace

Drupal\Tests\Core\Routing

Code

public function testMatchRequestAllowed() : void {
    $this->setupRouter();
    $request = new Request();
    $access_result = AccessResult::allowed();
    $this->accessManager
        ->expects($this->once())
        ->method('checkRequest')
        ->with($request)
        ->willReturn($access_result);
    $parameters = $this->accessAwareRouter
        ->matchRequest($request);
    $expected = [
        RouteObjectInterface::ROUTE_OBJECT => $this->route,
        AccessAwareRouterInterface::ACCESS_RESULT => $access_result,
    ];
    $this->assertSame($expected, $request->attributes
        ->all());
    $this->assertSame($expected, $parameters);
}

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