function TreeDataUnitTest::testMenuTreeData

Validate the generation of a proper menu tree hierarchy.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Menu/TreeDataUnitTest.php, line 38
Definition of Drupal\system\Tests\Menu\TreeDataUnitTest.

Class

TreeDataUnitTest
Menu tree data related tests.

Namespace

Drupal\system\Tests\Menu

Code

function testMenuTreeData() {
  $tree = menu_tree_data($this->links);

  // Validate that parent items #1, #2, and #5 exist on the root level.
  $this
    ->assertSameLink($this->links[1], $tree[1]['link'], 'Parent item #1 exists.');
  $this
    ->assertSameLink($this->links[2], $tree[2]['link'], 'Parent item #2 exists.');
  $this
    ->assertSameLink($this->links[5], $tree[5]['link'], 'Parent item #5 exists.');

  // Validate that child item #4 exists at the correct location in the hierarchy.
  $this
    ->assertSameLink($this->links[4], $tree[2]['below'][3]['below'][4]['link'], 'Child item #4 exists in the hierarchy.');
}