function MenuTreeOutputTestCase::testMenuTreeData

Validate the generation of a proper menu tree output.

File

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

Class

MenuTreeOutputTestCase
Menu tree output related tests.

Code

function testMenuTreeData() {
    $output = menu_tree_output($this->tree_data);
    // Validate that the - in main-menu is changed into an underscore
    $this->assertEqual($output['1']['#theme'], 'menu_link__main_menu', 'Hyphen is changed to an underscore on menu_link');
    $this->assertEqual($output['#theme_wrappers'][0], 'menu_tree__main_menu', 'Hyphen is changed to an underscore on menu_tree wrapper');
    // Looking for child items in the data
    $this->assertEqual($output['1']['#below']['2']['#href'], 'a/b', 'Checking the href on a child item');
    $this->assertTrue(in_array('active-trail', $output['1']['#below']['2']['#attributes']['class']), 'Checking the active trail class');
    // Validate that the hidden and no access items are missing
    $this->assertFalse(isset($output['5']), 'Hidden item should be missing');
    $this->assertFalse(isset($output['6']), 'False access should be missing');
    // Item 7 is after a couple hidden items. Just to make sure that 5 and 6 are skipped and 7 still included
    $this->assertTrue(isset($output['7']), 'Item after hidden items is present');
}

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