function MenuTestCase::testMenu
Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.
File
-
modules/
menu/ menu.test, line 32
Class
- MenuTestCase
- @file Tests for menu.module.
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);
// Test that the page title is correct when a local task appears in a
// top-level menu item. See https://www.drupal.org/node/1973262.
$item = $this->addMenuLink(0, 'user/register', 'user-menu');
$this->drupalGet('user/password');
$this->assertNoTitle('Home | Drupal');
$this->drupalLogout();
$this->drupalGet('user/register');
$this->assertTitle($item['link_title'] . ' | Drupal');
$this->drupalGet('user');
$this->assertNoTitle('Home | Drupal');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.