CurrentRouteMatch example


  protected function getRouteMatch($name, Route $route, array $parameters, array $raw_parameters) {
    $request_stack = new RequestStack();
    $request = new Request();
    $request_stack->push($request);

    $request = $request_stack->getCurrentRequest();
    $request->attributes = new ParameterBag($parameters);
    $request->attributes->set(RouteObjectInterface::ROUTE_NAME, $name);
    $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $route);
    $request->attributes->set('_raw_variables', new InputBag($raw_parameters));
    return new CurrentRouteMatch($request_stack);
  }

  /** * @covers ::__construct * @covers ::getRouteObject * @covers ::getCurrentRouteMatch * @covers ::getRouteMatch */
  public function testGetCurrentRouteObject() {

    $request_stack = new RequestStack();
    

  protected $lock;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->requestStack = new RequestStack();
    $this->currentRouteMatch = new CurrentRouteMatch($this->requestStack);
    $this->menuLinkManager = $this->createMock('Drupal\Core\Menu\MenuLinkManagerInterface');
    $this->cache = $this->createMock('\Drupal\Core\Cache\CacheBackendInterface');
    $this->lock = $this->createMock('\Drupal\Core\Lock\LockBackendInterface');

    $this->menuActiveTrail = new MenuActiveTrail($this->menuLinkManager, $this->currentRouteMatch, $this->cache, $this->lock);

    $container = new Container();
    $container->set('cache_tags.invalidator', $this->createMock('\Drupal\Core\Cache\CacheTagsInvalidatorInterface'));
    \Drupal::setContainer($container);
  }

  
Home | Imprint | This part of the site doesn't use cookies.