You are here

public function MenuUiTest::deleteMenuLink 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::deleteMenuLink()

Deletes a menu link using the UI.

Parameters

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

1 call to MenuUiTest::deleteMenuLink()
MenuUiTest::testMenu in core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
Tests menu functionality using the admin and user interfaces.

File

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

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 deleteMenuLink(MenuLinkContent $item) {
  $mlid = $item
    ->id();
  $title = $item
    ->getTitle();

  // Delete menu link.
  $this
    ->drupalGet("admin/structure/menu/item/{$mlid}/delete");
  $this
    ->submitForm([], 'Delete');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains("The menu link {$title} has been deleted.");

  // Verify deletion.
  $this
    ->drupalGet('');
  $this
    ->assertSession()
    ->pageTextNotContains($title);
}