You are here

protected function MenuRouterTest::doTestMenuHierarchy in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Menu/MenuRouterTest.php \Drupal\system\Tests\Menu\MenuRouterTest::doTestMenuHierarchy()

Tests for menu hierarchy.

1 call to MenuRouterTest::doTestMenuHierarchy()
MenuRouterTest::testMenuIntegration in core/modules/system/src/Tests/Menu/MenuRouterTest.php
Tests menu integration.

File

core/modules/system/src/Tests/Menu/MenuRouterTest.php, line 157
Contains \Drupal\system\Tests\Menu\MenuRouterTest.

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\system\Tests\Menu

Code

protected function doTestMenuHierarchy() {

  /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
  $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
  $menu_links = $menu_link_manager
    ->loadLinksByRoute('menu_test.hierarchy_parent');
  $parent_link = reset($menu_links);
  $menu_links = $menu_link_manager
    ->loadLinksByRoute('menu_test.hierarchy_parent_child');
  $child_link = reset($menu_links);
  $menu_links = $menu_link_manager
    ->loadLinksByRoute('menu_test.hierarchy_parent_child2');
  $unattached_child_link = reset($menu_links);
  $this
    ->assertEqual($child_link
    ->getParent(), $parent_link
    ->getPluginId(), 'The parent of a directly attached child is correct.');
  $this
    ->assertEqual($unattached_child_link
    ->getParent(), $child_link
    ->getPluginId(), 'The parent of a non-directly attached child is correct.');
}