function MenuUiTest::modifyMenuLink

Same name in other branches
  1. 9 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::modifyMenuLink()
  2. 8.9.x core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::modifyMenuLink()
  3. 11.x core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::modifyMenuLink()

Modifies a menu link using the UI.

Parameters

\Drupal\menu_link_content\Entity\MenuLinkContent $item: Menu link entity.

2 calls to MenuUiTest::modifyMenuLink()
MenuUiTest::doMenuTests in core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
Tests menu functionality.
MenuUiTest::testUnpublishedNodeMenuItem in core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
Tests that menu items pointing to unpublished nodes are editable.

File

core/modules/menu_ui/tests/src/Functional/MenuUiTest.php, line 924

Class

MenuUiTest
Tests the menu UI.

Namespace

Drupal\Tests\menu_ui\Functional

Code

public function modifyMenuLink(MenuLinkContent $item) {
    $item->title->value = $this->randomMachineName(16);
    $menu_link_id = $item->id();
    $title = $item->getTitle();
    // Edit menu link.
    $edit = [];
    $edit['title[0][value]'] = $title;
    $this->drupalGet("admin/structure/menu/item/{$menu_link_id}/edit");
    $this->submitForm($edit, 'Save');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->pageTextContains('The menu link has been saved.');
    // Verify menu link.
    $this->drupalGet('admin/structure/menu/manage/' . $item->getMenuName());
    $this->assertSession()
        ->pageTextContains($title);
}

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