You are here

public function DisplayPageTest::testMenuLinks in Drupal 10

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

Tests the generated menu links of views.

File

core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php, line 127

Class

DisplayPageTest
Tests the page display plugin.

Namespace

Drupal\Tests\views\Kernel\Plugin

Code

public function testMenuLinks() {
  \Drupal::service('plugin.manager.menu.link')
    ->rebuild();
  $tree = \Drupal::menuTree()
    ->load('admin', new MenuTreeParameters());
  $this
    ->assertTrue(isset($tree['system.admin']->subtree['views_view:views.test_page_display_menu.page_4']));
  $menu_link = $tree['system.admin']->subtree['views_view:views.test_page_display_menu.page_4']->link;
  $this
    ->assertEquals('Test child (with parent)', $menu_link
    ->getTitle());
  $this
    ->assertEquals(TRUE, $menu_link
    ->isExpanded());
  $this
    ->assertEquals('Sample description.', $menu_link
    ->getDescription());
}