diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php index ddc834b..1f86e08 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/LinksTest.php @@ -24,10 +24,11 @@ public static function getInfo() { /** * Create a simple hierarchy of links. */ - function createLinkHierarchy($module = 'menu_test') { + function createLinkHierarchy($module = 'menu_test', $name = 'menu_test', $truncate = TRUE) { // First remove all the menu links. - $menu_links = menu_link_load_multiple(); - menu_link_delete_multiple(array_keys($menu_links), TRUE, TRUE); + if ($truncate) { + db_truncate('menu_links')->execute(); + } // Then create a simple link hierarchy: // - $parent @@ -38,7 +39,7 @@ function createLinkHierarchy($module = 'menu_test') { $base_options = array( 'link_title' => 'Menu link test', 'module' => $module, - 'menu_name' => 'menu_test', + 'menu_name' => $name, ); $links['parent'] = $base_options + array( @@ -172,6 +173,29 @@ function testMenuLinkReparenting($module = 'menu_test') { 'child-2' => FALSE, ); $this->assertMenuLinkParents($links, $expected_hierarchy); + + // Start over, move child-1 from menu_test to menu_test2. + $links1 = $this->createLinkHierarchy($module); + $links2 = $this->createLinkHierarchy($module, 'menu_test2', FALSE); + $links1['child-1']['plid'] = $links2['parent']['mlid']; + menu_link_save($links1['child-1']); + + $expected_hierarchy1 = array( + 'parent' => FALSE, + 'child-2' => 'parent', + ); + $expected_hierarchy2 = array( + 'parent' => FALSE, + 'child-1' => 'parent', + 'child-1-1' => 'child-1', + 'child-1-2' => 'child-1', + 'child-1' => 'parent', + 'child-1-1' => 'child-1', + 'child-1-2' => 'child-1', + 'child-2' => 'parent', + ); + $this->assertMenuLinkParents($links1, $expected_hierarchy1); + $this->assertMenuLinkParents($links2, $expected_hierarchy2); } /**