public function MenuLinksTest::testModuleUninstalledMenuLinks in Drupal 10
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()
- 9 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 312
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);
}