1 menu.test | MenuTestCase::testMenu() |
Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.
File
- core/
modules/ menu/ tests/ menu.test, line 36 - Tests for menu.module.
Class
Code
function testMenu() {
// Login the user.
$this->backdropLogin($this->big_user);
$this->items = array();
// Add Main menu block into sidebar.
$layout = layout_load('default');
$layout->addBlock('system', 'main-menu', 'sidebar');
$layout->save();
// Do standard menu tests.
$this->doStandardMenuTests();
// Do custom menu tests.
$this->doCustomMenuTests();
// Do standard user tests.
// Login the user.
$this->backdropLogin($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->backdropLogin($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 for the correct behavior of user menu titles.
config_set('system.core', 'user_register', USER_REGISTER_VISITORS);
$this->addMenuLink(0, 'user/register', 'user-menu');
$this->backdropLogout();
$this->backdropGet('user/register');
$this->assertTitle('Create new account | Backdrop CMS');
$this->backdropGet('user/password');
$this->assertTitle('Reset password | Backdrop CMS');
$this->backdropGet('user/login');
$this->assertTitle('Log in | Backdrop CMS');
$this->backdropGet('user');
$this->assertTitle('Log in | Backdrop CMS');
}