1.20.x menu.test | MenuTestCase::addCustomMenuCRUD() |
Add custom menu using CRUD functions.
File
- modules/
menu/ tests/ menu.test, line 122 - Tests for menu.module.
Class
Code
function addCustomMenuCRUD() {
// Add a new custom menu.
$menu_name = substr(hash('sha256', $this->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
$title = $this->randomName(16);
$menu = array(
'menu_name' => $menu_name,
'title' => $title,
'description' => 'Description text',
);
menu_save($menu);
// Assert the new menu.
$this->backdropGet('admin/structure/menu/manage/' . $menu_name . '/edit');
$this->assertRaw($title, 'Custom menu was added.');
// Edit the menu.
$new_title = $this->randomName(16);
$menu['title'] = $new_title;
menu_save($menu);
$this->backdropGet('admin/structure/menu/manage/' . $menu_name . '/edit');
$this->assertRaw($new_title, 'Custom menu was edited.');
}