function MenuUiTest::testMenuUiWithPendingRevisions
Same name in other branches
- 8.9.x core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testMenuUiWithPendingRevisions()
- 10 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testMenuUiWithPendingRevisions()
- 11.x core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testMenuUiWithPendingRevisions()
Tests that menu links with pending revisions can not be re-parented.
File
-
core/
modules/ menu_ui/ tests/ src/ Functional/ MenuUiTest.php, line 1105
Class
- MenuUiTest
- Tests the menu UI.
Namespace
Drupal\Tests\menu_ui\FunctionalCode
public function testMenuUiWithPendingRevisions() {
$this->drupalLogin($this->adminUser);
$assert_session = $this->assertSession();
// Add four menu links in two separate menus.
$menu_1 = $this->addCustomMenu();
$root_1 = $this->addMenuLink('', '/', $menu_1->id());
$this->addMenuLink($root_1->getPluginId(), '/', $menu_1->id());
$menu_2 = $this->addCustomMenu();
$root_2 = $this->addMenuLink('', '/', $menu_2->id());
$child_2 = $this->addMenuLink($root_2->getPluginId(), '/', $menu_2->id());
$this->drupalGet('admin/structure/menu/manage/' . $menu_2->id());
$assert_session->pageTextNotContains($menu_2->label() . ' contains 1 menu link with pending revisions. Manipulation of a menu tree having links with pending revisions is not supported, but you can re-enable manipulation by getting each menu link to a published state.');
$this->drupalGet('admin/structure/menu/manage/' . $menu_1->id());
$assert_session->pageTextNotContains($menu_1->label() . ' contains 1 menu link with pending revisions. Manipulation of a menu tree having links with pending revisions is not supported, but you can re-enable manipulation by getting each menu link to a published state.');
// Create a pending revision for one of the menu links and check that it can
// no longer be re-parented in the UI. We can not create pending revisions
// through the UI yet so we have to use API calls.
\Drupal::entityTypeManager()->getStorage('menu_link_content')
->createRevision($child_2, FALSE)
->save();
$this->drupalGet('admin/structure/menu/manage/' . $menu_2->id());
$assert_session->pageTextContains($menu_2->label() . ' contains 1 menu link with pending revisions. Manipulation of a menu tree having links with pending revisions is not supported, but you can re-enable manipulation by getting each menu link to a published state.');
// Check that the 'Enabled' checkbox is hidden for a pending revision.
$this->assertNotEmpty($this->cssSelect('input[name="links[menu_plugin_id:' . $root_2->getPluginId() . '][enabled]"]'), 'The publishing status of a default revision can be changed.');
$this->assertEmpty($this->cssSelect('input[name="links[menu_plugin_id:' . $child_2->getPluginId() . '][enabled]"]'), 'The publishing status of a pending revision can not be changed.');
$this->drupalGet('admin/structure/menu/manage/' . $menu_1->id());
$assert_session->pageTextNotContains($menu_1->label() . ' contains 1 menu link with pending revisions. Manipulation of a menu tree having links with pending revisions is not supported, but you can re-enable manipulation by getting each menu link to a published state.');
// Check that the menu overview form can be saved without errors when there
// are pending revisions.
$this->drupalGet('admin/structure/menu/manage/' . $menu_2->id());
$this->submitForm([], 'Save');
$this->assertSession()
->elementNotExists('xpath', '//div[contains(@class, "messages--error")]');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.