You are here

public function MenuUiTest::modifyMenuLink in Drupal 8

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

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
    ->drupalPostForm("admin/structure/menu/item/{$mlid}/edit", $edit, t('Save'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertText('The menu link has been saved.');

  // Verify menu link.
  $this
    ->drupalGet('admin/structure/menu/manage/' . $item
    ->getMenuName());
  $this
    ->assertText($title, 'Menu link was edited');
}