You are here

public function MenuLinksOriginTest::testModuleUninstalledMenuLinks in Menu Item Extras 8.2

Tests uninstalling a module providing default links.

File

tests/src/Kernel/MenuLinksOriginTest.php, line 318

Class

MenuLinksOriginTest
Tests handling of menu links hierarchies.

Namespace

Drupal\Tests\menu_item_extras\Kernel

Code

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
    ->assertEquals(1, count($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
    ->assertEquals(0, count($menu_links));
}