function MenuTestCase::addCustomMenuCRUD

Add custom menu using CRUD functions.

1 call to MenuTestCase::addCustomMenuCRUD()
MenuTestCase::doCustomMenuTests in modules/menu/menu.test
Test custom menu functionality using navigation menu.

File

modules/menu/menu.test, line 111

Class

MenuTestCase
@file Tests for menu.module.

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->drupalGet('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->drupalGet('admin/structure/menu/manage/' . $menu_name . '/edit');
    $this->assertRaw($new_title, 'Custom menu was edited.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.