public function MenuLinksTest::testModuleUninstalledMenuLinks in Drupal 9
Same name and namespace in other branches
- 8 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('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);
}