/**
  * Constructs a Drupal\menu_trail_by_path\MenuTrailByPathLinkTree object.
  *
  * @param \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  * @param \Drupal\Core\Cache\CacheBackendInterface $cache
  * @param \Drupal\Core\Lock\LockBackendInterface $lock
  * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
  * @param \Drupal\Core\Path\CurrentPathStack $current_path_stack
  * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
  */
 public function __construct(MenuLinkManagerInterface $menu_link_manager, RouteMatchInterface $route_match, CacheBackendInterface $cache, LockBackendInterface $lock, LanguageManagerInterface $language_manager, CurrentPathStack $current_path_stack, AliasManagerInterface $alias_manager)
 {
     parent::__construct($menu_link_manager, $route_match, $cache, $lock);
     $this->language_manager = $language_manager;
     $this->current_path_stack = $current_path_stack;
     $this->alias_manager = $alias_manager;
 }
 /**
  * Tests getActiveTrailIds().
  *
  * @covers ::getActiveTrailIds
  * @dataProvider provider
  */
 public function testGetActiveTrailIds(Request $request, $links, $menu_name, $expected_link, $expected_trail)
 {
     $expected_trail_ids = array_combine($expected_trail, $expected_trail);
     $this->requestStack->push($request);
     if ($links !== FALSE) {
         $this->menuLinkManager->expects($this->once())->method('loadLinksbyRoute')->with('baby_llama')->will($this->returnValue($links));
         if ($expected_link !== NULL) {
             $this->menuLinkManager->expects($this->once())->method('getParentIds')->will($this->returnValueMap(array(array($expected_link->getPluginId(), $expected_trail_ids))));
         }
     }
     $this->assertSame($expected_trail_ids, $this->menuActiveTrail->getActiveTrailIds($menu_name));
 }
Example #3
0
 /**
  * Tests getCid()
  *
  * @covers ::getCid
  */
 public function testGetCid()
 {
     $data = $this->provider()[1];
     /** @var \Symfony\Component\HttpFoundation\Request $request */
     $request = $data[0];
     /** @var \Symfony\Component\Routing\Route $route */
     $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
     $route->setPath('/test/{b}/{a}');
     $request->attributes->get('_raw_variables')->add(['b' => 1, 'a' => 0]);
     $this->requestStack->push($request);
     $this->menuLinkManager->expects($this->any())->method('loadLinksbyRoute')->with('baby_llama')->will($this->returnValue($data[1]));
     $expected_link = $data[3];
     $expected_trail = $data[4];
     $expected_trail_ids = array_combine($expected_trail, $expected_trail);
     $this->menuLinkManager->expects($this->any())->method('getParentIds')->will($this->returnValueMap(array(array($expected_link->getPluginId(), $expected_trail_ids))));
     $this->assertSame($expected_trail_ids, $this->menuActiveTrail->getActiveTrailIds($data[2]));
     $this->cache->expects($this->once())->method('set')->with('active-trail:route:baby_llama:route_parameters:' . serialize(['a' => 0, 'b' => 1]));
     $this->lock->expects($this->any())->method('acquire')->willReturn(TRUE);
     $this->menuActiveTrail->destruct();
 }