function AccessAwareRouterTest::testCall

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

Ensure that methods are passed to the wrapped router.

@covers ::__call

File

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

Class

AccessAwareRouterTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Routing%21AccessAwareRouter.php/class/AccessAwareRouter/10" title="A router class for Drupal with access check and upcasting." class="local">\Drupal\Core\Routing\AccessAwareRouter</a> @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testCall() : void {
    $mock_router = $this->createMock(RouterInterface::class);
    $this->router = $this->getMockBuilder(MockRouterInterface::class)
        ->disableOriginalConstructor()
        ->onlyMethods([
        'getRouteCollection',
        'match',
        'getContext',
        'setContext',
        'generate',
        'add',
    ])
        ->getMock();
    $this->router
        ->expects($this->once())
        ->method('add')
        ->with($mock_router)
        ->willReturnSelf();
    $this->accessAwareRouter = new AccessAwareRouter($this->router, $this->accessManager, $this->currentUser);
    $this->accessAwareRouter
        ->add($mock_router);
}

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