public function BootstrapMenuItemsBasicTest::addMenuLink in Bootstrap menu items 8.3
Same name and namespace in other branches
- 7.3 bootstrap_menu_items.test \BootstrapMenuItemsBasicTest::addMenuLink()
CORE menu module clone.
Add a menu link using the menu module UI.
Parameters
int $plid: Parent menu link id.
string $link: Link path.
string $menu_name: Menu name.
bool $expanded: Menu expanded or not.
Return value
array Menu link created.
1 call to BootstrapMenuItemsBasicTest::addMenuLink()
- BootstrapMenuItemsBasicTest::testBootstrapMenuItemsMenuTests in src/
Tests/ BootstrapMenuItemsBasicTest.php - Test custom menu items.
File
- src/
Tests/ BootstrapMenuItemsBasicTest.php, line 134 - Test file for Bootstrap menu items module.
Class
- BootstrapMenuItemsBasicTest
- Test basic functionality of Bootstrap menu items module.
Code
public function addMenuLink($plid = 0, $link = '<front>', $menu_name = 'navigation', $expanded = TRUE) {
// View add menu link page.
$this
->drupalGet("admin/structure/menu/manage/{$menu_name}/add");
$this
->assertResponse(200);
$title = '!link_' . $this
->randomName(16);
$edit = array(
'link_path' => $link,
'link_title' => $title,
// Use this to disable the menu and test.
'description' => '',
'enabled' => TRUE,
// Setting this to true should test whether it works when we do the
// std_user tests.
'expanded' => $expanded,
'parent' => $menu_name . ':' . $plid,
'weight' => '0',
);
// Add menu link.
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertResponse(200);
// Unlike most other modules, there is no confirmation message displayed.
$this
->assertText($title, 'Menu link was added');
$item = db_query('SELECT * FROM {menu_links} WHERE link_title = :title', array(
':title' => $title,
))
->fetchAssoc();
$this
->assertTrue(t('Menu link was found in database.'));
$this
->assertMenuLink($item['mlid'], array(
'menu_name' => $menu_name,
'link_path' => $link,
'has_children' => 0,
'plid' => $plid,
));
return $item;
}