public function MenuLinksTest::assertMenuLinkParents in Drupal 10
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()
- 9 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.
@internal
File
- core/
modules/ menu_link_content/ tests/ src/ Kernel/ MenuLinksTest.php, line 126
Class
- MenuLinksTest
- Tests handling of menu links hierarchies.
Namespace
Drupal\Tests\menu_link_content\KernelCode
public function assertMenuLinkParents(array $links, array $expected_hierarchy) : void {
foreach ($expected_hierarchy as $id => $parent) {
/** @var \Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin */
$menu_link_plugin = $this->menuLinkManager
->createInstance($links[$id]);
$expected_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,
]));
}
}