You are here

public function LinksTest::testModuleUninstalledMenuLinks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/menu_link_content/src/Tests/LinksTest.php \Drupal\menu_link_content\Tests\LinksTest::testModuleUninstalledMenuLinks()

Tests uninstalling a module providing default links.

File

core/modules/menu_link_content/src/Tests/LinksTest.php, line 201
Contains \Drupal\menu_link_content\Tests\LinksTest.

Class

LinksTest
Tests handling of menu links hierarchies.

Namespace

Drupal\menu_link_content\Tests

Code

public function testModuleUninstalledMenuLinks() {
  \Drupal::service('module_installer')
    ->install(array(
    'menu_test',
  ));
  \Drupal::service('router.builder')
    ->rebuild();
  \Drupal::service('plugin.manager.menu.link')
    ->rebuild();
  $menu_links = $this->menuLinkManager
    ->loadLinksByRoute('menu_test.menu_test');
  $this
    ->assertEqual(count($menu_links), 1);
  $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(array(
    'menu_test',
  ));
  \Drupal::service('plugin.manager.menu.link')
    ->rebuild();
  $menu_links = $this->menuLinkManager
    ->loadLinksByRoute('menu_test.menu_test');
  $this
    ->assertEqual(count($menu_links), 0);
}