MenuActiveTrail example


  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);
  }

  /** * Provides test data for all test methods. * * @return array * Returns a list of test data of which each is an array containing the * following elements: * - request: A request object. * - links: An array of menu links keyed by ID. * - menu_name: The active menu name. * - expected_link: The expected active link for the given menu. */
Home | Imprint | This part of the site doesn't use cookies.