public function MenuLinksTest::assertMenuLinkParents in Drupal 9
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::assertMenuLinkParents()
Assert that at set of links is properly parented.
1 call to MenuLinksTest::assertMenuLinkParents()
- MenuLinksTest::testMenuLinkReparenting in core/
modules/ menu_link_content/ tests/ src/ Kernel/ MenuLinksTest.php - Tests automatic reparenting of menu links.
File
- core/
modules/ menu_link_content/ tests/ src/ Kernel/ MenuLinksTest.php, line 124
Class
- MenuLinksTest
- Tests handling of menu links hierarchies.
Namespace
Drupal\Tests\menu_link_content\KernelCode
public function assertMenuLinkParents($links, $expected_hierarchy) {
foreach ($expected_hierarchy as $id => $parent) {
/** @var \Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin */
$menu_link_plugin = $this->menuLinkManager
->createInstance($links[$id]);
$expected_parent = isset($links[$parent]) ? $links[$parent] : '';
$this
->assertEquals($expected_parent, $menu_link_plugin
->getParent(), new FormattableMarkup('Menu link %id has parent of %parent, expected %expected_parent.', [
'%id' => $id,
'%parent' => $menu_link_plugin
->getParent(),
'%expected_parent' => $expected_parent,
]));
}
}