summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/menu.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-14 20:23:01 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-14 20:23:01 +0000
commit0c2b526539f7fb50765bf9ef2dfa7c573764f9fd (patch)
treea024987330cd00d3881ed8aa1b17f10858168d34 /modules/simpletest/tests/menu.test
parent13984a7394ec27a2e99b6c7437469f663a331cc3 (diff)
downloadbrdo-0c2b526539f7fb50765bf9ef2dfa7c573764f9fd.tar.gz
brdo-0c2b526539f7fb50765bf9ef2dfa7c573764f9fd.tar.bz2
- Patch #631550 by sun: fixed stale and improper logic for MENU_VISIBLE_IN_TREE and MENU_VISIBLE_IN_BREADCRUMB. Added lots of code comments, and added tests.
Diffstat (limited to 'modules/simpletest/tests/menu.test')
-rw-r--r--modules/simpletest/tests/menu.test99
1 files changed, 94 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() {