public function MenuAdminPerMenuNodeFormTest::testResaveMenuLinkWithoutAccess in Menu Admin per Menu 8
Test menu re-save by users without permission.
Tests that a menu still exists and remains existing if a user without the menu permissions re-saves a node.
File
- tests/
src/ Functional/ MenuAdminPerMenuNodeFormTest.php, line 140
Class
- MenuAdminPerMenuNodeFormTest
- Tests the interaction of the node system with menu links.
Namespace
Drupal\Tests\menu_admin_per_menu\FunctionalCode
public function testResaveMenuLinkWithoutAccess() {
$menu_link_title = $this
->randomString();
// Save the node with the menu.
$this
->drupalLogin($this->contentAndMenuUser);
$this
->drupalGet('node/add/page');
$this
->submitForm([
'title[0][value]' => $this
->randomString(),
'body[0][value]' => $this
->randomString(),
'menu[enabled]' => 1,
'menu[title]' => $menu_link_title,
], 'Save');
// Ensure the menu is in place.
$this
->assertSession()
->linkExists($menu_link_title);
// Logout.
$this
->drupalLogout();
// Save the node again as someone without permission.
$this
->drupalLogin($this->contentOnlyUser);
$this
->drupalGet('node/add/page');
$this
->submitForm([
'title[0][value]' => $this
->randomString(),
'body[0][value]' => $this
->randomString(),
], 'Save');
// Ensure the menu is still in place.
$this
->assertSession()
->linkExists($menu_link_title);
// Ensure anonymous users with "access content" permission can see this
// menu.
$this
->drupalLogout();
$this
->drupalGet('');
$this
->assertSession()
->linkExists($menu_link_title);
}