summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/menu.test99
-rw-r--r--modules/simpletest/tests/menu_test.module106
2 files changed, 200 insertions, 5 deletions
diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test
index 475dac334..4a34369fe 100644
--- a/modules/simpletest/tests/menu.test
+++ b/modules/simpletest/tests/menu.test
@@ -6,11 +6,11 @@
* Provides SimpleTests for menu.inc.
*/
-class MenuIncTestCase extends DrupalWebTestCase {
+class MenuRouterTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
- 'name' => 'Hook menu tests',
- 'description' => 'Test menu hook functionality.',
+ 'name' => 'Menu router',
+ 'description' => 'Tests menu router and hook_menu() functionality.',
'group' => 'Menu',
);
}
@@ -197,9 +197,9 @@ class MenuIncTestCase extends DrupalWebTestCase {
}
/**
- * Tests for menu hiearchy.
+ * Tests for menu hierarchy.
*/
- function testMenuHiearchy() {
+ function testMenuHierarchy() {
$parent_link = db_query('SELECT * FROM {menu_links} WHERE link_path = :link_path', array(':link_path' => 'menu-test/hierarchy/parent'))->fetchAssoc();
$child_link = db_query('SELECT * FROM {menu_links} WHERE link_path = :link_path', array(':link_path' => 'menu-test/hierarchy/parent/child'))->fetchAssoc();
$unattached_child_link = db_query('SELECT * FROM {menu_links} WHERE link_path = :link_path', array(':link_path' => 'menu-test/hierarchy/parent/child2/child'))->fetchAssoc();
@@ -209,6 +209,95 @@ class MenuIncTestCase extends DrupalWebTestCase {
}
/**
+ * Tests menu link depth and parents of local tasks and menu callbacks.
+ */
+ function testMenuHidden() {
+ // Verify links for one dynamic argument.
+ $links = db_select('menu_links', 'ml')
+ ->fields('ml')
+ ->condition('ml.router_path', 'menu-test/hidden/menu%', 'LIKE')
+ ->orderBy('ml.router_path')
+ ->execute()
+ ->fetchAllAssoc('router_path', PDO::FETCH_ASSOC);
+
+ $parent = $links['menu-test/hidden/menu'];
+ $depth = $parent['depth'] + 1;
+ $plid = $parent['mlid'];
+
+ $link = $links['menu-test/hidden/menu/list'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/menu/add'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/menu/settings'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/menu/manage/%'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $parent = $links['menu-test/hidden/menu/manage/%'];
+ $depth = $parent['depth'] + 1;
+ $plid = $parent['mlid'];
+
+ $link = $links['menu-test/hidden/menu/manage/%/list'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/menu/manage/%/add'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/menu/manage/%/edit'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/menu/manage/%/delete'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ // Verify links for two dynamic arguments.
+ $links = db_select('menu_links', 'ml')
+ ->fields('ml')
+ ->condition('ml.router_path', 'menu-test/hidden/block%', 'LIKE')
+ ->orderBy('ml.router_path')
+ ->execute()
+ ->fetchAllAssoc('router_path', PDO::FETCH_ASSOC);
+
+ $parent = $links['menu-test/hidden/block'];
+ $depth = $parent['depth'] + 1;
+ $plid = $parent['mlid'];
+
+ $link = $links['menu-test/hidden/block/list'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/block/add'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/block/manage/%/%'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $parent = $links['menu-test/hidden/block/manage/%/%'];
+ $depth = $parent['depth'] + 1;
+ $plid = $parent['mlid'];
+
+ $link = $links['menu-test/hidden/block/manage/%/%/configure'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+
+ $link = $links['menu-test/hidden/block/manage/%/%/delete'];
+ $this->assertEqual($link['depth'], $depth, t('%path depth @link_depth is equal to @depth.', array('%path' => $link['router_path'], '@link_depth' => $link['depth'], '@depth' => $depth)));
+ $this->assertEqual($link['plid'], $plid, t('%path plid @link_plid is equal to @plid.', array('%path' => $link['router_path'], '@link_plid' => $link['plid'], '@plid' => $plid)));
+ }
+
+ /**
* Test menu_set_item().
*/
function testMenuSetItem() {
diff --git a/modules/simpletest/tests/menu_test.module b/modules/simpletest/tests/menu_test.module
index a89451780..264861240 100644
--- a/modules/simpletest/tests/menu_test.module
+++ b/modules/simpletest/tests/menu_test.module
@@ -58,6 +58,112 @@ function menu_test_menu() {
'page arguments' => array(TRUE),
'access arguments' => array('access content'),
);
+
+ // Hidden tests; base parents.
+ // Same structure as in Menu and Block modules. Since those structures can
+ // change, we need to simulate our own in here.
+ $items['menu-test'] = array(
+ 'title' => 'Menu test root',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ );
+ $items['menu-test/hidden'] = array(
+ 'title' => 'Menu test parent',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ );
+
+ // Hidden tests; one dynamic argument.
+ $items['menu-test/hidden/menu'] = array(
+ 'title' => 'Menus',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ );
+ $items['menu-test/hidden/menu/list'] = array(
+ 'title' => 'List menus',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['menu-test/hidden/menu/add'] = array(
+ 'title' => 'Add menu',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_LOCAL_ACTION,
+ );
+ $items['menu-test/hidden/menu/settings'] = array(
+ 'title' => 'Settings',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 5,
+ );
+ $items['menu-test/hidden/menu/manage/%menu'] = array(
+ 'title' => 'Customize menu',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['menu-test/hidden/menu/manage/%menu/list'] = array(
+ 'title' => 'List links',
+ 'weight' => -10,
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
+ );
+ $items['menu-test/hidden/menu/manage/%menu/add'] = array(
+ 'title' => 'Add link',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_LOCAL_ACTION,
+ );
+ $items['menu-test/hidden/menu/manage/%menu/edit'] = array(
+ 'title' => 'Edit menu',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_LOCAL_TASK,
+ 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
+ );
+ $items['menu-test/hidden/menu/manage/%menu/delete'] = array(
+ 'title' => 'Delete menu',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Hidden tests; two dynamic arguments.
+ $items['menu-test/hidden/block'] = array(
+ 'title' => 'Blocks',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ );
+ $items['menu-test/hidden/block/list'] = array(
+ 'title' => 'List',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['menu-test/hidden/block/add'] = array(
+ 'title' => 'Add block',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_LOCAL_ACTION,
+ );
+ $items['menu-test/hidden/block/manage/%/%'] = array(
+ 'title' => 'Configure block',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ );
+ $items['menu-test/hidden/block/manage/%/%/configure'] = array(
+ 'title' => 'Configure block',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'context' => MENU_CONTEXT_INLINE,
+ );
+ $items['menu-test/hidden/block/manage/%/%/delete'] = array(
+ 'title' => 'Delete block',
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_LOCAL_TASK,
+ 'context' => MENU_CONTEXT_NONE,
+ );
+
return $items;
}