public function BootstrapMenuItemsBasicTest::testBootstrapMenuItemsMenuTests in Bootstrap menu items 8.3
Same name and namespace in other branches
- 7.3 bootstrap_menu_items.test \BootstrapMenuItemsBasicTest::testBootstrapMenuItemsMenuTests()
Test custom menu items.
File
- src/
Tests/ BootstrapMenuItemsBasicTest.php, line 44 - Test file for Bootstrap menu items module.
Class
- BootstrapMenuItemsBasicTest
- Test basic functionality of Bootstrap menu items module.
Code
public function testBootstrapMenuItemsMenuTests($menu_name = 'navigation') {
// Add nodes to use as links for menu links.
$node1 = $this
->drupalCreateNode(array(
'type' => 'article',
));
$node2 = $this
->drupalCreateNode(array(
'type' => 'article',
));
$node3 = $this
->drupalCreateNode(array(
'type' => 'article',
));
$node4 = $this
->drupalCreateNode(array(
'type' => 'article',
));
$node5 = $this
->drupalCreateNode(array(
'type' => 'article',
));
// Add menu links.
$item1 = $this
->addMenuLink(0, '<nolink>', $menu_name, TRUE);
$item2 = $this
->addMenuLink($item1['mlid'], 'node/' . $node2->nid, $menu_name);
$item3 = $this
->addMenuLink($item1['mlid'], 'node/' . $node3->nid, $menu_name);
$item4 = $this
->addMenuLink($item1['mlid'], '<separator>', $menu_name);
$item5 = $this
->addMenuLink($item1['mlid'], '<header>', $menu_name);
$item6 = $this
->addMenuLink($item1['mlid'], 'node/' . $node4->nid, $menu_name);
$item7 = $this
->addMenuLink($item1['mlid'], 'node/' . $node5->nid, $menu_name);
$this
->assertMenuLink($item1['mlid'], array(
'depth' => 1,
'has_children' => 1,
'p1' => $item1['mlid'],
'p2' => 0,
));
$this
->assertMenuLink($item2['mlid'], array(
'depth' => 2,
'has_children' => 0,
'p1' => $item1['mlid'],
'p2' => $item2['mlid'],
'p3' => 0,
));
$this
->assertMenuLink($item3['mlid'], array(
'depth' => 2,
'has_children' => 0,
'p1' => $item1['mlid'],
'p2' => $item3['mlid'],
'p3' => 0,
));
$this
->assertMenuLink($item4['mlid'], array(
'depth' => 2,
'has_children' => 0,
'p1' => $item1['mlid'],
'p2' => $item4['mlid'],
'p3' => 0,
));
$this
->assertMenuLink($item5['mlid'], array(
'depth' => 2,
'has_children' => 0,
'p1' => $item1['mlid'],
'p2' => $item5['mlid'],
'p3' => 0,
));
$this
->assertMenuLink($item6['mlid'], array(
'depth' => 2,
'has_children' => 0,
'p1' => $item1['mlid'],
'p2' => $item6['mlid'],
'p3' => 0,
));
$this
->assertMenuLink($item6['mlid'], array(
'depth' => 2,
'has_children' => 0,
'p1' => $item1['mlid'],
'p2' => $item6['mlid'],
'p3' => 0,
));
$this
->drupalGet('');
$this
->assertTrue($this
->xpath('//a[@href="#" and contains(@class, :class)]', array(
':class' => 'nolink',
)), 'Top level menu link found.');
$this
->assertTrue($this
->xpath('//li[contains(@class, :class)]', array(
':class' => 'dropdown-header',
)), 'Menu header found.');
$this
->assertTrue($this
->xpath('//li[@role=:role and contains(@class, :class)]', array(
':role' => 'separator',
':class' => 'divider',
)), 'Menu separator found.');
$this
->assertFieldByXPath('//li[contains(@class, "dropdown-header")]', $item5['link_title'], 'Menu header name found.');
$this
->assertFieldByXPath('//li[@role="separator" and contains(@class, "divider")]', $item4['link_title'], 'Menu separator name found.');
}