You are here

public function MenuLinkReorderTest::testDefaultMenuLinkReorder in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php \Drupal\Tests\menu_ui\Functional\MenuLinkReorderTest::testDefaultMenuLinkReorder()

Tests creating, editing, deleting menu links via node form widget.

File

core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php, line 36

Class

MenuLinkReorderTest
Reorder menu items.

Namespace

Drupal\Tests\menu_ui\Functional

Code

public function testDefaultMenuLinkReorder() {

  // Add the main menu block.
  $this
    ->drupalPlaceBlock('system_menu_block:main');

  // Assert that the Home link is available.
  $this
    ->drupalGet('test-page');
  $this
    ->assertSession()
    ->linkExists('Home');

  // The administrator user that can re-order menu links.
  $this->administrator = $this
    ->drupalCreateUser([
    'administer site configuration',
    'access administration pages',
    'administer menu',
  ]);
  $this
    ->drupalLogin($this->administrator);

  // Change the weight of the link to a non default value.
  $edit = [
    'links[menu_plugin_id:test_page_test.front_page][weight]' => -10,
  ];
  $this
    ->drupalGet('admin/structure/menu/manage/main');
  $this
    ->submitForm($edit, 'Save');

  // The link is still there.
  $this
    ->drupalGet('test-page');
  $this
    ->assertSession()
    ->linkExists('Home');

  // Clear all caches.
  $this
    ->drupalGet('admin/config/development/performance');
  $this
    ->submitForm([], 'Clear all caches');

  // Clearing all caches should not affect the state of the menu link.
  $this
    ->drupalGet('test-page');
  $this
    ->assertSession()
    ->linkExists('Home');
}