public function MenuAdminPerMenuMenuPagesTest::testMenuLinkContentPages in Menu Admin per Menu 8
Test the menu_link_content pages.
File
- tests/
src/ Functional/ MenuAdminPerMenuMenuPagesTest.php, line 554
Class
- MenuAdminPerMenuMenuPagesTest
- Tests the Menu pages in combination with Menu Admin per Menu.
Namespace
Drupal\Tests\menu_admin_per_menu\FunctionalCode
public function testMenuLinkContentPages() {
$assert_session = $this
->assertSession();
$menu_1_link = $this
->createMenuContentLink([
'menu_name' => $this->menu1
->id(),
]);
$menu_2_link = $this
->createMenuContentLink([
'menu_name' => $this->menu2
->id(),
]);
$menu_3_link = $this
->createMenuContentLink([
'menu_name' => $this->menu3
->id(),
]);
// Anonymous users doesn't have access to any of the pages.
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
// An authenticated user without permissions doesn't have access to this
// page.
$this
->drupalLogin($this->authenticatedUser);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
// Admin users have access to all menus.
$this
->drupalLogin($this->rootUser);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
// Users with the 'administer menu' permission can edit all menus and menu
// links.
$this
->drupalLogin($this->adminMenuUser);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
// Check that list of parent options is not filtered.
$assert_session
->optionExists('menu_parent', 'menu_1:menu_1.link');
$assert_session
->optionExists('menu_parent', 'menu_2:menu_2.link');
$assert_session
->optionExists('menu_parent', 'menu_3:menu_3.link');
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
// Users with 'administer menu_1 menu items' only have access to menu_1.
$this
->drupalLogin($this->menu1User);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
// Check that list of parent options is filtered.
$assert_session
->optionExists('menu_parent', 'menu_1:menu_1.link');
$assert_session
->optionNotExists('menu_parent', 'menu_2:menu_2.link');
$assert_session
->optionNotExists('menu_parent', 'menu_3:menu_3.link');
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
// Users with 'administer menu_2 menu items' only have access to menu_2.
$this
->drupalLogin($this->menu2User);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
// Check that list of parent options is filtered.
$assert_session
->optionNotExists('menu_parent', 'menu_1:menu_1.link');
$assert_session
->optionExists('menu_parent', 'menu_2:menu_2.link');
$assert_session
->optionNotExists('menu_parent', 'menu_3:menu_3.link');
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(403);
// Permission for this user was added by
// hook_menu_admin_per_menu_get_permissions_alter.
$this
->drupalLogin($this->menu3User);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_1_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_2_link
->id()));
$assert_session
->statusCodeEquals(403);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
// Check that list of parent options is filtered.
$assert_session
->optionNotExists('menu_parent', 'menu_1:menu_1.link');
$assert_session
->optionNotExists('menu_parent', 'menu_2:menu_2.link');
$assert_session
->optionExists('menu_parent', 'menu_3:menu_3.link');
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/delete', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
$this
->drupalGet(sprintf('admin/structure/menu/item/%s/edit/translations/add/en/fr', $menu_3_link
->id()));
$assert_session
->statusCodeEquals(200);
}