Add custom menu using CRUD functions.
function addCustomMenuCRUD() {
// Add a new custom menu.
$menu_name = substr(hash('sha256', $this
->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
$label = $this
->randomName(16);
$menu = entity_create('menu', array(
'id' => $menu_name,
'label' => $label,
'description' => 'Description text',
));
$menu
->save();
// Assert the new menu.
$this
->drupalGet('admin/structure/menu/manage/' . $menu_name);
$this
->assertRaw($label, 'Custom menu was added.');
// Edit the menu.
$new_label = $this
->randomName(16);
$menu
->set('label', $new_label);
$menu
->save();
$this
->drupalGet('admin/structure/menu/manage/' . $menu_name);
$this
->assertRaw($new_label, 'Custom menu was edited.');
}