You are here

public function MenuUiTest::deleteMenuLink in Drupal 10

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()
  2. 9 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.

File

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

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);
}