function BreadcrumbPreprocessTest::testMenuLinkEditForm
Same name and namespace in other branches
- 11.x core/themes/default_admin/tests/src/Kernel/BreadcrumbPreprocessTest.php \Drupal\Tests\default_admin\Kernel\BreadcrumbPreprocessTest::testMenuLinkEditForm()
Tests the case this was reported for: editing a custom menu link.
Menu links are what users actually hit this on, because a menu link's bundle key holds the bare string 'menu_link_content' rather than a reference to a bundle entity.
The assertion deliberately does not touch the bundle field. Whether the menu link keeps its bundle key or loses it, the breadcrumb has no bundle entity to name it and falls back to the entity type's singular label, so this stays true either way.
See also
https://www.drupal.org/project/drupal/issues/3613636
File
-
core/
themes/ default_admin/ tests/ src/ Kernel/ BreadcrumbPreprocessTest.php, line 92
Class
- BreadcrumbPreprocessTest
- Tests breadcrumb preprocessing for entities.
Namespace
Drupal\Tests\default_admin\KernelCode
public function testMenuLinkEditForm() : void {
$link = MenuLinkContent::create([
'title' => 'A menu link',
'link' => [
'uri' => 'internal:/',
],
'menu_name' => 'admin',
]);
$link->save();
$variables = $this->preprocessBreadcrumb($link, 'entity.menu_link_content.edit_form');
$this->assertSame('Edit Custom menu link', (string) end($variables['breadcrumb'])['text']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.