function MenuLinksTest::testModuleUninstalledMenuLinks
Same name in other branches
- 9 core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php \Drupal\Tests\menu_link_content\Kernel\MenuLinksTest::testModuleUninstalledMenuLinks()
- 10 core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php \Drupal\Tests\menu_link_content\Kernel\MenuLinksTest::testModuleUninstalledMenuLinks()
- 11.x core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php \Drupal\Tests\menu_link_content\Kernel\MenuLinksTest::testModuleUninstalledMenuLinks()
Tests uninstalling a module providing default links.
File
-
core/
modules/ menu_link_content/ tests/ src/ Kernel/ MenuLinksTest.php, line 310
Class
- MenuLinksTest
- Tests handling of menu links hierarchies.
Namespace
Drupal\Tests\menu_link_content\KernelCode
public function testModuleUninstalledMenuLinks() {
\Drupal::service('module_installer')->install([
'menu_test',
]);
\Drupal::service('router.builder')->rebuild();
\Drupal::service('plugin.manager.menu.link')->rebuild();
$menu_links = $this->menuLinkManager
->loadLinksByRoute('menu_test.menu_test');
$this->assertCount(1, $menu_links);
$menu_link = reset($menu_links);
$this->assertEqual($menu_link->getPluginId(), 'menu_test');
// Uninstall the module and ensure the menu link got removed.
\Drupal::service('module_installer')->uninstall([
'menu_test',
]);
\Drupal::service('plugin.manager.menu.link')->rebuild();
$menu_links = $this->menuLinkManager
->loadLinksByRoute('menu_test.menu_test');
$this->assertCount(0, $menu_links);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.