function MenuAttributesTestHelper::crudMenuLink in Menu Attributes 7
Add or edit a menu link using the menu module UI.
Parameters
integer $plid Parent menu link id.:
string $link Link path.:
string $menu_name Menu name.:
Return value
array Menu link created.
1 call to MenuAttributesTestHelper::crudMenuLink()
- MenuAttributesTestCase::testMenuAttributes in ./
menu_attributes.test - Tests menu attributes functionality.
File
- ./
menu_attributes.test, line 66 - Functionality tests for Menu attributes.
Class
- MenuAttributesTestHelper
- Helper test class with some added functions for testing.
Code
function crudMenuLink($mlid = 0, $plid = 0, $link = '<front>', $menu_name = 'navigation') {
// View add/edit menu link page.
if (empty($mlid)) {
$this
->drupalGet("admin/structure/menu/manage/{$menu_name}/add");
$menu_attributes = $this->menu_attributes_new;
}
else {
$this
->drupalGet("admin/structure/menu/item/{$mlid}/edit");
$menu_attributes = $this->menu_attributes_edit;
}
$this
->assertResponse(200);
$title = '!link_' . $this
->randomName(16);
$edit = array(
'link_path' => $link,
'link_title' => $title,
'enabled' => TRUE,
// Use this to disable the menu and test.
'expanded' => TRUE,
// Setting this to true should test whether it works when we do the std_user tests.
'parent' => $menu_name . ':' . $plid,
'weight' => '0',
'options[attributes][title]' => $menu_attributes['title'],
'options[attributes][id]' => $menu_attributes['id'],
'options[attributes][name]' => $menu_attributes['name'],
'options[attributes][rel]' => $menu_attributes['rel'],
'options[attributes][class]' => $menu_attributes['class'],
'options[attributes][style]' => $menu_attributes['style'],
'options[attributes][target]' => $menu_attributes['target'],
'options[attributes][accesskey]' => $menu_attributes['accesskey'],
);
// Add menu link.
$this
->drupalPost(NULL, $edit, t('Save'));
$item = db_query('SELECT * FROM {menu_links} WHERE link_title = :title', array(
':title' => $title,
))
->fetchAssoc();
return $item;
}