protected function MenuRouterTest::doTestMenuLinksDiscoveredAlter in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/Tests/Menu/MenuRouterTest.php \Drupal\system\Tests\Menu\MenuRouterTest::doTestMenuLinksDiscoveredAlter()
Tests menu links added in hook_menu_links_discovered_alter().
1 call to MenuRouterTest::doTestMenuLinksDiscoveredAlter()
- MenuRouterTest::testMenuIntegration in core/
modules/ system/ src/ Tests/ Menu/ MenuRouterTest.php - Tests menu integration.
File
- core/
modules/ system/ src/ Tests/ Menu/ MenuRouterTest.php, line 139 - Contains \Drupal\system\Tests\Menu\MenuRouterTest.
Class
- MenuRouterTest
- Tests menu router and default menu link functionality.
Namespace
Drupal\system\Tests\MenuCode
protected function doTestMenuLinksDiscoveredAlter() {
// Check that machine name does not need to be defined since it is already
// set as the key of each menu link.
/** @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.custom');
$menu_link = reset($menu_links);
$this
->assertEqual($menu_link
->getPluginId(), 'menu_test.custom', 'Menu links added at hook_menu_links_discovered_alter() obtain the machine name from the $links key.');
// Make sure that rebuilding the menu tree does not produce duplicates of
// links added by hook_menu_links_discovered_alter().
\Drupal::service('router.builder')
->rebuild();
$this
->drupalGet('menu-test');
$this
->assertUniqueText('Custom link', 'Menu links added by hook_menu_links_discovered_alter() do not duplicate after a menu rebuild.');
}