diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 3a55eba..b678bb8 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2700,6 +2700,7 @@ function menu_default_links_rebuild() { else { if (empty($link['route_name']) && empty($link['link_path'])) { $link['route_name'] = ''; + $link['link_title'] = 'THIS IS A BUG'; } $menu_link = $menu_link_controller->create($link); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php index ab55143..b882567 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php @@ -62,10 +62,8 @@ function setUp() { */ public function testMenuIntegration() { $this->doTestTitleMenuCallback(); - $this->doTestMenuSetItem(); $this->doTestMenuOptionalPlaceholders(); $this->doTestMenuOnRoute(); - $this->doTestMenuHidden(); $this->doTestMenuGetItemNoAncestors(); $this->doTestMenuName(); $this->doTestMenuItemTitlesCases(); @@ -209,87 +207,6 @@ protected function doTestMenuHierarchy() { } /** - * Tests menu link depth and parents of local tasks and menu callbacks. - */ - protected function doTestMenuHidden() { - // Verify links for one dynamic argument. - $query = \Drupal::entityQuery('menu_link') - ->condition('link_path', 'menu-test/hidden/menu', 'STARTS_WITH') - ->sort('link_path'); - $result = $query->execute(); - $menu_links = menu_link_load_multiple($result); - - $links = array(); - foreach ($menu_links as $menu_link) { - $links[$menu_link->link_path] = $menu_link; - } - - $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, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_path'], '@link_plid' => $link['plid'], '@plid' => $plid))); - - $link = $links['menu-test/hidden/menu/settings']; - $this->assertEqual($link['depth'], $depth, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_path'], '@link_plid' => $link['plid'], '@plid' => $plid))); - - $link = $links['menu-test/hidden/menu/manage/%']; - $this->assertEqual($link['depth'], $depth, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_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, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_path'], '@link_plid' => $link['plid'], '@plid' => $plid))); - - $link = $links['menu-test/hidden/menu/manage/%/edit']; - $this->assertEqual($link['depth'], $depth, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_path'], '@link_plid' => $link['plid'], '@plid' => $plid))); - - $link = $links['menu-test/hidden/menu/manage/%/delete']; - $this->assertEqual($link['depth'], $depth, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_path'], '@link_plid' => $link['plid'], '@plid' => $plid))); - - // Verify links for two dynamic arguments. - $query = \Drupal::entityQuery('menu_link') - ->condition('link_path', 'menu-test/hidden/block', 'STARTS_WITH') - ->sort('link_path'); - $result = $query->execute(); - $menu_links = menu_link_load_multiple($result); - - $links = array(); - foreach ($menu_links as $menu_link) { - $links[$menu_link->link_path] = $menu_link; - } - - $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, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_path'], '@link_plid' => $link['plid'], '@plid' => $plid))); - - $link = $links['menu-test/hidden/block/manage/%/%']; - $this->assertEqual($link['depth'], $depth, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_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/%/%/delete']; - $this->assertEqual($link['depth'], $depth, format_string('%path depth @link_depth is equal to @depth.', array('%path' => $link['link_path'], '@link_depth' => $link['depth'], '@depth' => $depth))); - $this->assertEqual($link['plid'], $plid, format_string('%path plid @link_plid is equal to @plid.', array('%path' => $link['link_path'], '@link_plid' => $link['plid'], '@plid' => $plid))); - } - - /** * Test menu_get_item() with empty ancestors. */ protected function doTestMenuGetItemNoAncestors() { @@ -298,23 +215,6 @@ protected function doTestMenuGetItemNoAncestors() { } /** - * Test menu_set_item(). - */ - protected function doTestMenuSetItem() { - $item = menu_get_item('test-page'); - - $this->assertEqual($item['path'], 'test-page', "Path from menu_get_item('test-page') is equal to 'test-page'", 'menu'); - - // Modify the path for the item then save it. - $item['path'] = 'test-page-test'; - $item['href'] = 'test-page-test'; - - menu_set_item('test-page', $item); - $compare_item = menu_get_item('test-page'); - $this->assertEqual($compare_item, $item, 'Modified menu item is equal to newly retrieved menu item.', 'menu'); - } - - /** * Test menu maintenance hooks. */ protected function doTestMenuItemHooks() { diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module index eb3a9de..0f40f40 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.module +++ b/core/modules/system/tests/modules/menu_test/menu_test.module @@ -323,8 +323,6 @@ function menu_test_default_menu_links() { // This item tests using a description callback. $items['menu_callback_description.description-callback'] = array( 'link_title' => 'Menu item with a description set with a callback', - 'description callback' => 'check_plain', - 'description arguments' => array('Menu item description arguments'), 'route_name' => 'menu_test.callback_description_callback', 'parent' => 'menu_callback_description', ); @@ -332,8 +330,6 @@ function menu_test_default_menu_links() { $items['menu_no_title_callback'] = array( 'link_title' => 'A title with @placeholder', 'title' => 'A title with @placeholder', - 'title callback' => FALSE, - 'title arguments' => array('@placeholder' => 'some other text'), 'route_name' => 'menu_test.menu_no_title_callback', ); @@ -353,12 +349,13 @@ function menu_test_default_menu_links() { 'parent' => 'menu_test.hierarchy_parent.child', ); // Path containing "exotic" characters. - $path = "menu-test/ -._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters. + $exotic = " -._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters. "%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string. "éøïвβ中國書۞"; // Characters from various non-ASCII alphabets. - $items[$path] = array( + $items['menu_test.exotic_path'] = array( 'link_title' => '"Exotic" path', 'route_name' => 'menu_test.exotic_path', + 'route_parameters' => array('exotic' => $exotic), ); // Hidden tests; base parents. @@ -390,28 +387,45 @@ function menu_test_default_menu_links() { // Menu trail tests. // @see MenuTrailTestCase - $items['menu-test/menu-trail'] = array( + $items['menu-test.menu-trail'] = array( 'link_title' => 'Menu trail - Case 1', 'route_name' => 'menu_test.menu_trail', 'parent' => 'menu-test', ); - $items['admin/config/development/menu-trail'] = array( + $items['admin.config.development.menu-trail'] = array( 'link_title' => 'Menu trail - Case 2', 'description' => 'Tests menu_tree_set_path()', 'route_name' => 'menu_test.menu_trail_admin', 'parent' => 'admin.config.development', ); - $items['menu-test/custom-403-page'] = array( + $items['menu-test.custom-403-page'] = array( 'link_title' => 'Custom 403 page', 'route_name' => 'menu_test.custom_403', 'parent' => 'menu-test', ); - $items['menu-test/custom-404-page'] = array( + $items['menu-test.custom-404-page'] = array( 'link_title' => 'Custom 404 page', 'route_name' => 'menu_test.custom_404', 'parent' => 'menu-test', ); - + // Test the access key. + $items['menu-title-test.case1'] = array( + 'link_title' => 'Example title - Case 1', + 'route_name' => 'menu_test.title_test_case1', + ); + $items['menu-title-test.case2'] = array( + 'link_title' => 'Example @sub1 - Case @op2', + 'route_name' => 'menu_test.title_test_case2', + ); + $items['menu-title-test.case3'] = array( + 'link_title' => 'Example title', + 'route_name' => 'menu_test.title_test_case3', + ); + $items['menu-title-test.case4'] = array( + // Title gets completely ignored. Good thing, too. + 'link_title' => 'Bike sheds full of blue smurfs', + 'route_name' => 'menu_test.title_test_case4', + ); return $items; }