function MenuUiNodeAccessTest::testMenuLinkCreateAccess

Tests menu link create access is enforced.

File

core/modules/menu_ui/tests/src/Functional/MenuUiNodeAccessTest.php, line 45

Class

MenuUiNodeAccessTest
Edit a node when you don't have permission to add or edit menu links.

Namespace

Drupal\Tests\menu_ui\Functional

Code

public function testMenuLinkCreateAccess() : void {
    $this->drupalLogin($this->drupalCreateUser([
        'administer menu',
        'edit any page content',
    ]));
    $node = Node::create([
        'type' => 'page',
        'title' => $this->randomMachineName(),
        'uid' => $this->rootUser
            ->id(),
        'status' => 1,
    ]);
    $node->save();
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()
        ->elementNotExists('css', 'input[name="menu[title]"]');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.