You are here

function MenuTest::modifyMenuLink in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/menu_ui/src/Tests/MenuTest.php \Drupal\menu_ui\Tests\MenuTest::modifyMenuLink()

Modifies a menu link using the UI.

Parameters

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

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

File

core/modules/menu_ui/src/Tests/MenuTest.php, line 760
Contains \Drupal\menu_ui\Tests\MenuTest.

Class

MenuTest
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\menu_ui\Tests

Code

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

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