X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=inline;f=web%2Fcore%2Fmodules%2Fmenu_link_content%2Ftests%2Fsrc%2FKernel%2FPlugin%2Fmigrate%2Fsource%2FMenuLinkTest.php;fp=web%2Fcore%2Fmodules%2Fmenu_link_content%2Ftests%2Fsrc%2FKernel%2FPlugin%2Fmigrate%2Fsource%2FMenuLinkTest.php;h=7fb3a918f836e1485c193a4f6076b0c7c9ef0d3e;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php b/web/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php new file mode 100644 index 000000000..7fb3a918f --- /dev/null +++ b/web/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php @@ -0,0 +1,225 @@ + 'menu-test-menu', + 'mlid' => 140, + 'plid' => 0, + 'link_path' => 'admin/config/system/cron', + 'router_path' => 'admin/config/system/cron', + 'link_title' => 'Cron', + 'options' => [], + 'module' => 'system', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 0, + 'depth' => 0, + 'customized' => 1, + 'p1' => '0', + 'p2' => '0', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + 'description' => '', + ], + [ + // D6 customized menu link, provided by menu module. + 'menu_name' => 'menu-test-menu', + 'mlid' => 141, + 'plid' => 0, + 'link_path' => 'node/141', + 'router_path' => 'node/%', + 'link_title' => 'Node 141', + 'options' => [], + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 0, + 'depth' => 0, + 'customized' => 1, + 'p1' => '0', + 'p2' => '0', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + 'description' => '', + ], + [ + // D6 non-customized menu link, provided by menu module. + 'menu_name' => 'menu-test-menu', + 'mlid' => 142, + 'plid' => 0, + 'link_path' => 'node/142', + 'router_path' => 'node/%', + 'link_title' => 'Node 142', + 'options' => [], + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 0, + 'depth' => 0, + 'customized' => 0, + 'p1' => '0', + 'p2' => '0', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + 'description' => '', + ], + [ + 'menu_name' => 'menu-test-menu', + 'mlid' => 138, + 'plid' => 0, + 'link_path' => 'admin', + 'router_path' => 'admin', + 'link_title' => 'Test 1', + 'options' => ['attributes' => ['title' => 'Test menu link 1']], + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 1, + 'expanded' => 0, + 'weight' => 15, + 'depth' => 1, + 'customized' => 1, + 'p1' => '138', + 'p2' => '0', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + 'description' => 'Test menu link 1', + ], + [ + 'menu_name' => 'menu-test-menu', + 'mlid' => 139, + 'plid' => 138, + 'link_path' => 'admin/modules', + 'router_path' => 'admin/modules', + 'link_title' => 'Test 2', + 'options' => ['attributes' => ['title' => 'Test menu link 2']], + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 12, + 'depth' => 2, + 'customized' => 1, + 'p1' => '138', + 'p2' => '139', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + 'description' => 'Test menu link 2', + ], + [ + 'menu_name' => 'menu-user', + 'mlid' => 143, + 'plid' => 0, + 'link_path' => 'admin/build/menu-customize/navigation', + 'router_path' => 'admin/build/menu-customize/%', + 'link_title' => 'Navigation', + 'options' => [], + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 0, + 'depth' => 0, + 'customized' => 0, + 'p1' => '0', + 'p2' => '0', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + 'description' => '', + ], + ]; + + // Add long link title attributes to source data. + $title = $this->getRandomGenerator()->string('500'); + $tests[0]['source_data']['menu_links'][0]['options']['attributes']['title'] = $title; + + // Build the expected results. + $expected = $tests[0]['source_data']['menu_links']; + + // Add long link title attributes to expected results. + $expected[0]['description'] = Unicode::truncate($title, 255); + + // Don't expect D6 menu link to a custom menu, provided by menu module. + unset($expected[5]); + + array_walk($tests[0]['source_data']['menu_links'], function (&$row) { + $row['options'] = serialize($row['options']); + }); + + $tests[0]['expected_data'] = $expected; + + return $tests; + } + +}