/**
  * Tests the checkNamedRoute with default values.
  *
  * @covers \Drupal\Core\Access\AccessManager::checkNamedRoute()
  */
 public function testCheckNamedRouteWithDefaultValue()
 {
     $this->routeCollection = new RouteCollection();
     $route = new Route('/test-route-1/{value}', array('value' => 'example'), array('_test_access' => 'TRUE'));
     $this->routeCollection->add('test_route_1', $route);
     $this->routeProvider = $this->getMock('Drupal\\Core\\Routing\\RouteProviderInterface');
     $this->routeProvider->expects($this->any())->method('getRouteByName')->with('test_route_1', array())->will($this->returnValue($route));
     $map = array();
     $map[] = array('test_route_1', array('value' => 'example'), '/test-route-1/example');
     $this->urlGenerator = $this->getMock('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface');
     $this->urlGenerator->expects($this->any())->method('generate')->with('test_route_1', array())->will($this->returnValueMap($map));
     $this->paramConverter = $this->getMock('Drupal\\Core\\ParamConverter\\ParamConverterManagerInterface');
     $this->paramConverter->expects($this->at(0))->method('convert')->with(array('value' => 'example', RouteObjectInterface::ROUTE_OBJECT => $route))->will($this->returnValue(array('value' => 'upcasted_value')));
     $this->argumentsResolver->expects($this->atLeastOnce())->method('getArguments')->will($this->returnCallback(function ($callable, $route, $request, $account) {
         return array($route);
     }));
     $subrequest = Request::create('/test-route-1/example');
     $this->accessManager = new AccessManager($this->routeProvider, $this->urlGenerator, $this->paramConverter, $this->argumentsResolver, $this->requestStack);
     $this->accessManager->setContainer($this->container);
     $this->requestStack->push(new Request());
     $access_check = $this->getMock('Drupal\\Tests\\Core\\Access\\TestAccessCheckInterface');
     $access_check->expects($this->atLeastOnce())->method('applies')->will($this->returnValue(TRUE));
     $access_check->expects($this->atLeastOnce())->method('access')->will($this->returnValue(AccessInterface::KILL));
     $subrequest->attributes->set('value', 'upcasted_value');
     $this->container->set('test_access', $access_check);
     $this->accessManager->addCheckService('test_access', 'access');
     $this->accessManager->setChecks($this->routeCollection);
     $this->assertFalse($this->accessManager->checkNamedRoute('test_route_1', array(), $this->account));
 }
 /**
  * Apply access checks to routes.
  *
  * @param \Drupal\Core\Routing\RouteBuildEvent $event
  *   The event to process.
  */
 public function onRoutingRouteAlterSetAccessCheck(RouteBuildEvent $event)
 {
     $this->accessManager->setChecks($event->getRouteCollection());
 }