You are here

protected function MenuRouterTest::doTestMenuHierarchy in Drupal 10

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

Tests for menu hierarchy.

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

File

core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php, line 149

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\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
    ->assertEquals($parent_link
    ->getPluginId(), $child_link
    ->getParent(), 'The parent of a directly attached child is correct.');
  $this
    ->assertEquals($child_link
    ->getPluginId(), $unattached_child_link
    ->getParent(), 'The parent of a non-directly attached child is correct.');
}