/**
* Tests deleting all the links in a menu.
*/
public function testDeleteLinksInMenu() { \Drupal::
entityTypeManager()->
getStorage('menu'
)->
create(['id' => 'menu1'
])->
save();
\Drupal::
entityTypeManager()->
getStorage('menu'
)->
create(['id' => 'menu2'
])->
save();
\Drupal::
entityTypeManager()->
getStorage('menu_link_content'
)->
create(['link' =>
['uri' => 'internal:/menu_name_test'
], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'
])->
save();
\Drupal::
entityTypeManager()->
getStorage('menu_link_content'
)->
create(['link' =>
['uri' => 'internal:/menu_name_test'
], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'
])->
save();
\Drupal::
entityTypeManager()->
getStorage('menu_link_content'
)->
create(['link' =>
['uri' => 'internal:/menu_name_test'
], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content', 'title' => 'Link test'
])->
save();
$output =
$this->linkTree->
load('menu1',
new MenuTreeParameters());
$this->
assertCount(2,
$output);
$output =
$this->linkTree->
load('menu2',
new MenuTreeParameters());
$this->
assertCount(1,
$output);
$this->menuLinkManager->
deleteLinksInMenu('menu1'
);
$output =
$this->linkTree->
load('menu1',
new MenuTreeParameters());
$this->
assertCount(0,
$output);
$output =
$this->linkTree->
load('menu2',
new MenuTreeParameters());
$this->
assertCount(1,
$output);
}