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()
- 8.9.x 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 314
Class
- MenuLinksTest
- Tests handling of menu links hierarchies.
Namespace
Drupal\Tests\menu_link_content\KernelCode
public function testModuleUninstalledMenuLinks() : void {
\Drupal::service('module_installer')->install([
'menu_test',
]);
\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->assertEquals('menu_test', $menu_link->getPluginId());
// 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.