public function MenuUiTest::testUnpublishedNodeMenuItem in Drupal 10
Same name and namespace in other branches
- 8 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testUnpublishedNodeMenuItem()
- 9 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testUnpublishedNodeMenuItem()
Tests that menu items pointing to unpublished nodes are editable.
File
- core/
modules/ menu_ui/ tests/ src/ Functional/ MenuUiTest.php, line 646
Class
- MenuUiTest
- Add a custom menu, add menu links to the custom menu and Tools menu, check their data, and delete them using the UI.
Namespace
Drupal\Tests\menu_ui\FunctionalCode
public function testUnpublishedNodeMenuItem() {
$this
->drupalLogin($this
->drupalCreateUser([
'access administration pages',
'administer blocks',
'administer menu',
'create article content',
'bypass node access',
]));
// Create an unpublished node.
$node = $this
->drupalCreateNode([
'type' => 'article',
'status' => NodeInterface::NOT_PUBLISHED,
]);
$item = $this
->addMenuLink('', '/node/' . $node
->id());
$this
->modifyMenuLink($item);
// Test that a user with 'administer menu' but without 'bypass node access'
// cannot see the menu item.
$this
->drupalLogout();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/structure/menu/manage/' . $item
->getMenuName());
$this
->assertSession()
->pageTextNotContains($item
->getTitle());
// The cache contexts associated with the (in)accessible menu links are
// bubbled. See DefaultMenuLinkTreeManipulators::menuLinkCheckAccess().
$this
->assertSession()
->responseHeaderContains('X-Drupal-Cache-Contexts', 'user.permissions');
}