You are here

public function MenuNodeAPITestCase::menuNodeAPIDeleteLink in Menu Node API 7

Helper function to delete a menu link.

Parameters

$is_node: Selects link that is a node (or is not).

2 calls to MenuNodeAPITestCase::menuNodeAPIDeleteLink()
MenuNodeAPIBasicTestCase::testMenuNodeAPI in tests/menu_node.test
Tests for basic internal module functions.
MenuNodeAPIHookTestCase::testMenuNodeAPIHooks in tests/menu_node.test
Run tests against the menu_node_test.module.

File

tests/menu_node.test, line 112
Simpletest for Menu Node API.

Class

MenuNodeAPITestCase
Utility test class that provides methods for other tests.

Code

public function menuNodeAPIDeleteLink($is_node = TRUE) {
  $query = db_select('menu_links', 'ml')
    ->fields('ml', array(
    'mlid',
  ))
    ->range(0, 1);
  if ($is_node) {
    $query
      ->join('menu_node', 'mn', 'ml.mlid = mn.mlid');
  }
  else {
    $query
      ->join('menu_node', 'mn', 'ml.mlid = mn.mlid AND mn.mlid IS NULL');
    $query
      ->condition('ml.link_path', '<front>');
  }
  $result = $query
    ->execute();
  foreach ($result as $data) {
    menu_link_delete($data->mlid);
  }
}