You are here

public function ViewsMenuLinkTest::testMenuLinkOverrides in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Plugin/Display/ViewsMenuLinkTest.php \Drupal\Tests\views\Kernel\Plugin\Display\ViewsMenuLinkTest::testMenuLinkOverrides()
  2. 9 core/modules/views/tests/src/Kernel/Plugin/Display/ViewsMenuLinkTest.php \Drupal\Tests\views\Kernel\Plugin\Display\ViewsMenuLinkTest::testMenuLinkOverrides()

Tests views internal menu link options.

File

core/modules/views/tests/src/Kernel/Plugin/Display/ViewsMenuLinkTest.php, line 54

Class

ViewsMenuLinkTest
Menu link test.

Namespace

Drupal\Tests\views\Kernel\Plugin\Display

Code

public function testMenuLinkOverrides() {

  // Link from views module.
  $views_link = $this->menuLinkManager
    ->getDefinition('views_view:views.test_page_display_menu.page_3');
  $this
    ->assertTrue((bool) $views_link['enabled'], 'Menu link is enabled.');
  $this
    ->assertFalse((bool) $views_link['expanded'], 'Menu link is not expanded.');
  $views_link['enabled'] = 0;
  $views_link['expanded'] = 1;
  $this->menuLinkManager
    ->updateDefinition($views_link['id'], $views_link);
  $views_link = $this->menuLinkManager
    ->getDefinition($views_link['id']);
  $this
    ->assertFalse((bool) $views_link['enabled'], 'Menu link is disabled.');
  $this
    ->assertTrue((bool) $views_link['expanded'], 'Menu link is expanded.');
  $this->menuLinkManager
    ->rebuild();
  $this
    ->assertFalse((bool) $views_link['enabled'], 'Menu link is disabled.');
  $this
    ->assertTrue((bool) $views_link['expanded'], 'Menu link is expanded.');

  // Link from user module.
  $user_link = $this->menuLinkManager
    ->getDefinition('user.page');
  $this
    ->assertTrue((bool) $user_link['enabled'], 'Menu link is enabled.');
  $user_link['enabled'] = 0;
  $views_link['expanded'] = 1;
  $this->menuLinkManager
    ->updateDefinition($user_link['id'], $user_link);
  $this
    ->assertFalse((bool) $user_link['enabled'], 'Menu link is disabled.');
  $this->menuLinkManager
    ->rebuild();
  $this
    ->assertFalse((bool) $user_link['enabled'], 'Menu link is disabled.');
  $this->menuLinkOverrides
    ->reload();
  $views_link = $this->menuLinkManager
    ->getDefinition('views_view:views.test_page_display_menu.page_3');
  $this
    ->assertFalse((bool) $views_link['enabled'], 'Menu link is disabled.');
  $this
    ->assertTrue((bool) $views_link['expanded'], 'Menu link is expanded.');
  $user_link = $this->menuLinkManager
    ->getDefinition('user.page');
  $this
    ->assertFalse((bool) $user_link['enabled'], 'Menu link is disabled.');
}