You are here

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

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
    ->drupalPostForm("admin/structure/menu/link/{$menu_link->getPluginId()}/reset", [], t('Reset'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertRaw(t('The menu link was reset to its default settings.'), 'Menu link was reset');

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