You are here

public function MenuUiTest::modifyMenuLink in Drupal 9

Same name and namespace in other branches
  1. 8 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 790

Class

MenuUiTest
Add a custom menu, add menu links to the custom menu and Tools menu, check their data, and delete them using the UI.

Namespace

Drupal\Tests\menu_ui\Functional

Code

public function modifyMenuLink(MenuLinkContent $item) {
  $item->title->value = $this
    ->randomMachineName(16);
  $mlid = $item
    ->id();
  $title = $item
    ->getTitle();

  // Edit menu link.
  $edit = [];
  $edit['title[0][value]'] = $title;
  $this
    ->drupalGet("admin/structure/menu/item/{$mlid}/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);
}