function MenuLinkContentFormTest::testMenuLinkContentFormLinkToAnyPage
Same name in other branches
- 9 core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentFormTest::testMenuLinkContentFormLinkToAnyPage()
- 8.9.x core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentFormTest::testMenuLinkContentFormLinkToAnyPage()
- 11.x core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentFormTest::testMenuLinkContentFormLinkToAnyPage()
Tests the 'link to any page' permission for a restricted page.
File
-
core/
modules/ menu_link_content/ tests/ src/ Functional/ MenuLinkContentFormTest.php, line 61
Class
- MenuLinkContentFormTest
- Tests the menu link content UI.
Namespace
Drupal\Tests\menu_link_content\FunctionalCode
public function testMenuLinkContentFormLinkToAnyPage() : void {
$menu_link = MenuLinkContent::create([
'title' => 'Menu link test',
'provider' => 'menu_link_content',
'menu_name' => 'admin',
'link' => [
'uri' => 'internal:/user/login',
],
]);
$menu_link->save();
// The user should be able to edit a menu link to the page, even though
// the user cannot access the page itself.
$this->drupalGet('/admin/structure/menu/item/' . $menu_link->id() . '/edit');
$this->assertSession()
->statusCodeEquals(200);
// Test that other menus are available when editing existing menu link.
$this->assertSession()
->optionExists('edit-menu-parent', 'main:');
$this->drupalLogin($this->basicUser);
$this->drupalGet('/admin/structure/menu/item/' . $menu_link->id() . '/edit');
$this->assertSession()
->statusCodeEquals(403);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.