You are here

function MenuModuleEnable::testMenuModuleEnable in SimpleTest 6

File

tests/menu_module.test, line 157

Class

MenuModuleEnable

Code

function testMenuModuleEnable() {
  $web_user = $this
    ->drupalCreateUserRolePerm(array(
    'administer menu',
  ));
  $this
    ->drupalLoginUser($web_user);
  $this
    ->drupalGet('admin/build/menu-customize/navigation');
  $this
    ->clickLink('edit', 0);
  $url = $this
    ->getUrl();
  preg_match('/\\d+/', $url, $matches);
  $item = menu_link_load($matches[0]);
  $hidden = $item['hidden'];
  $edit['menu[enabled]'] = $hidden ? 1 : FALSE;
  $this
    ->assertTrue(TRUE, $hidden ? 'Disabled item found' : 'Enabled item found');
  $this
    ->drupalPost('admin/build/menu/item/' . $item['mlid'] . '/edit', $edit, 'Save');
  $item = menu_link_load($item['mlid']);
  $this
    ->assertTrue($item['hidden'] != $hidden, $item['hidden'] ? 'Item is now disabled' : 'Item is now enabled');
  $edit['menu[enabled]'] = $hidden ? FALSE : 1;
  $this
    ->drupalPost('admin/build/menu/item/' . $item['mlid'] . '/edit', $edit, 'Save');
  $item = menu_link_load($item['mlid']);
  $this
    ->assertTrue($item['hidden'] == $hidden, $item['hidden'] ? 'Item is disabled again' : 'Item is now enabled again');
}