protected function MenuRouterTest::doTestMenuLinksDiscoveredAlter in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::doTestMenuLinksDiscoveredAlter()
- 10 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::doTestMenuLinksDiscoveredAlter()
Tests menu links added in hook_menu_links_discovered_alter().
1 call to MenuRouterTest::doTestMenuLinksDiscoveredAlter()
- 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 132
Class
- MenuRouterTest
- Tests menu router and default menu link functionality.
Namespace
Drupal\Tests\system\Functional\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.');
}