function MenuUiTest::testUnpublishedNodeMenuItem
Same name in other branches
- 8.9.x core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testUnpublishedNodeMenuItem()
- 10 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testUnpublishedNodeMenuItem()
- 11.x 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 651
Class
- MenuUiTest
- Tests the menu 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');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.