function MenuTreeDataTestCase::testMenuTreeData

Validate the generation of a proper menu tree hierarchy.

File

modules/simpletest/tests/menu.test, line 954

Class

MenuTreeDataTestCase
Menu tree data related tests.

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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.