You are here

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

Resets a standard menu link using the UI.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $menu_link: The Menu link.

int $old_weight: Original title for menu link.

1 call to MenuUiTest::resetMenuLink()
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 816

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 resetMenuLink(MenuLinkInterface $menu_link, $old_weight) {

  // Reset menu link.
  $this
    ->drupalGet("admin/structure/menu/link/{$menu_link->getPluginId()}/reset");
  $this
    ->submitForm([], 'Reset');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('The menu link was reset to its default settings.');

  // Verify menu link.
  $instance = \Drupal::service('plugin.manager.menu.link')
    ->createInstance($menu_link
    ->getPluginId());
  $this
    ->assertEquals($old_weight, $instance
    ->getWeight(), 'Resets to the old weight.');
}