public function MenuLinkTreeTest::testDeleteLinksInMenu in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Menu/MenuLinkTreeTest.php \Drupal\system\Tests\Menu\MenuLinkTreeTest::testDeleteLinksInMenu()
Tests deleting all the links in a menu.
File
- core/
modules/ system/ src/ Tests/ Menu/ MenuLinkTreeTest.php, line 66 - Contains \Drupal\system\Tests\Menu\MenuLinkTreeTest.
Class
- MenuLinkTreeTest
- Tests the menu link tree.
Namespace
Drupal\system\Tests\MenuCode
public function testDeleteLinksInMenu() {
\Drupal::entityManager()
->getStorage('menu')
->create(array(
'id' => 'menu1',
))
->save();
\Drupal::entityManager()
->getStorage('menu')
->create(array(
'id' => 'menu2',
))
->save();
\Drupal::entityManager()
->getStorage('menu_link_content')
->create(array(
'link' => [
'uri' => 'internal:/menu_name_test',
],
'menu_name' => 'menu1',
'bundle' => 'menu_link_content',
))
->save();
\Drupal::entityManager()
->getStorage('menu_link_content')
->create(array(
'link' => [
'uri' => 'internal:/menu_name_test',
],
'menu_name' => 'menu1',
'bundle' => 'menu_link_content',
))
->save();
\Drupal::entityManager()
->getStorage('menu_link_content')
->create(array(
'link' => [
'uri' => 'internal:/menu_name_test',
],
'menu_name' => 'menu2',
'bundle' => 'menu_link_content',
))
->save();
$output = $this->linkTree
->load('menu1', new MenuTreeParameters());
$this
->assertEqual(count($output), 2);
$output = $this->linkTree
->load('menu2', new MenuTreeParameters());
$this
->assertEqual(count($output), 1);
$this->menuLinkManager
->deleteLinksInMenu('menu1');
$output = $this->linkTree
->load('menu1', new MenuTreeParameters());
$this
->assertEqual(count($output), 0);
$output = $this->linkTree
->load('menu2', new MenuTreeParameters());
$this
->assertEqual(count($output), 1);
}