diff options
Diffstat (limited to 'modules/simpletest/tests/menu.test')
-rw-r--r-- | modules/simpletest/tests/menu.test | 99 |
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() { |