function MenuTestCase::addCustomMenuCRUD

7.x menu.test MenuTestCase::addCustomMenuCRUD()

Add custom menu using CRUD functions.

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

File

drupal-7.x/modules/menu/menu.test, line 100
Tests for menu.module.

Class

MenuTestCase

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.');
}