1 system.test MenuBlockTestCase::addMenuLink($menu_name, $plid = 0, $link = 'user')

Add a menu link using the menu module UI.

Parameters

integer $plid Parent menu link id.:

string $link Link path.:

string $menu_name Menu name.:

Return value

array Menu link created.:

File

core/modules/system/tests/system.test, line 2891
Tests for system.module.

Class

MenuBlockTestCase
Test menu block settings.

Code

function addMenuLink($menu_name, $plid = 0, $link = 'user') {
  // View add menu link page.
  $this->backdropGet("admin/structure/menu/manage/$menu_name/add");
  $this->assertResponse(200);

  $title = '!link_' . $this->randomName(16);
  $edit = array(
    'link_path' => $link,
    'link_title' => $title,
    'description' => '',
    'enabled' => TRUE,
    'expanded' => TRUE,
    'parent' => $menu_name . ':' . $plid,
    'weight' => '0',
  );

  // Add menu link.
  $this->backdropPost(NULL, $edit, t('Save'));
  $this->assertResponse(200);
  // Unlike most other modules, there is no confirmation message displayed.
  $this->assertText($title, 'Menu link was added');

  $item = db_query('SELECT * FROM {menu_links} WHERE link_title = :title', array(':title' => $title))->fetchAssoc();
  $this->assertTrue(t('Menu link was found in database.'));

  return $item;
}