function MenuTestCase::testMenu
7.x menu.test | MenuTestCase::testMenu() |
Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.
File
- drupal-7.x/
modules/ menu/ menu.test, line 32 - Tests for menu.module.
Class
Code
function testMenu() {
// Login the user.
$this->drupalLogin($this->big_user);
$this->items = array();
// Do standard menu tests.
$this->doStandardMenuTests();
// Do custom menu tests.
$this->doCustomMenuTests();
// Do standard user tests.
// Login the user.
$this->drupalLogin($this->std_user);
$this->verifyAccess(403);
foreach ($this->items as $item) {
$node = node_load(substr($item['link_path'], 5)); // Paths were set as 'node/$nid'.
$this->verifyMenuLink($item, $node);
}
// Login the user.
$this->drupalLogin($this->big_user);
// Delete menu links.
foreach ($this->items as $item) {
$this->deleteMenuLink($item);
}
// Delete custom menu.
$this->deleteCustomMenu($this->menu);
// Modify and reset a standard menu link.
$item = $this->getStandardMenuLink();
$old_title = $item['link_title'];
$this->modifyMenuLink($item);
$item = menu_link_load($item['mlid']);
// Verify that a change to the description is saved.
$description = $this->randomName(16);
$item['options']['attributes']['title'] = $description;
menu_link_save($item);
$saved_item = menu_link_load($item['mlid']);
$this->assertEqual($description, $saved_item['options']['attributes']['title'], 'Saving an existing link updates the description (title attribute)');
$this->resetMenuLink($item, $old_title);
}