You are here

public function MenuHelperTestCase::testCreateLinks in Helper 7

File

tests/MenuHelperTestCase.test, line 32

Class

MenuHelperTestCase

Code

public function testCreateLinks() {
  $links = array(
    array(
      'link_path' => '<front>',
      'link_title' => 'Home',
    ),
    array(
      'link_path' => 'alias',
      'link_title' => 'Parent',
      'children' => array(
        array(
          'link_title' => 'Child',
          'children' => array(
            array(
              'link_path' => 'http://www.example.com/',
              'link_title' => 'Subchild',
            ),
          ),
        ),
      ),
    ),
    array(
      'link_path' => 'administration',
      'link_title' => 'Admin',
      'menu_name' => 'main-menu',
    ),
  );
  MenuHelper::createLinks($links, array(
    'menu_name' => 'helper',
    'link_path' => '<front>',
  ));
  $loaded_links = menu_load_links('helper');
  $this
    ->assertEqual(count($loaded_links), 4);
  $this
    ->assertEqual($loaded_links[0]['link_path'], '<front>');
  $this
    ->assertEqual($loaded_links[0]['link_title'], 'Home');
  $this
    ->assertEqual($loaded_links[0]['has_children'], FALSE);
  $this
    ->assertEqual($loaded_links[1]['link_path'], 'source');
  $this
    ->assertEqual($loaded_links[1]['link_title'], 'Parent');
  $this
    ->assertEqual($loaded_links[1]['has_children'], TRUE);
  $this
    ->assertEqual($loaded_links[2]['link_path'], '<front>');
  $this
    ->assertEqual($loaded_links[2]['link_title'], 'Child');
  $this
    ->assertEqual($loaded_links[2]['plid'], $loaded_links[1]['mlid']);
  $this
    ->assertEqual($loaded_links[2]['has_children'], TRUE);
  $this
    ->assertEqual($loaded_links[3]['link_path'], 'http://www.example.com/');
  $this
    ->assertEqual($loaded_links[3]['link_title'], 'Subchild');
  $this
    ->assertEqual($loaded_links[3]['plid'], $loaded_links[2]['mlid']);
  $this
    ->assertEqual($loaded_links[3]['has_children'], FALSE);
  $loaded_links = menu_load_links('main-menu');
  $this
    ->assertEqual(count($loaded_links), 1);
  $this
    ->assertEqual($loaded_links[0]['link_path'], 'admin');
  $this
    ->assertEqual($loaded_links[0]['link_title'], 'Admin');
  $this
    ->assertEqual($loaded_links[0]['has_children'], FALSE);
}