$menu->addChild('c2'); $menu->addChild('c3'); $menu->addChild('c4'); $menu['c3']->moveToFirstPosition(); $arr = array_keys($menu->getChildren()); $t->is($arr, array('c3', 'c1', 'c2', 'c4'), 'c3 moved to first position'); $menu['c2']->moveToLastPosition(); $arr = array_keys($menu->getChildren()); $t->is($arr, array('c3', 'c1', 'c4', 'c2'), 'c2 moved to last position'); $menu['c1']->moveToPosition(2); $arr = array_keys($menu->getChildren()); $t->is($arr, array('c3', 'c4', 'c1', 'c2'), 'c1 moved to 3rd position'); $menu->reorderChildren(array('c4', 'c3', 'c2', 'c1')); $arr = array_keys($menu->getChildren()); $t->is($arr, array('c4', 'c3', 'c2', 'c1'), 'reorder children'); $t->is($menu->render(), '<ul class="menu"><li class="first">c4</li><li>c3</li><li>c2</li><li class="last">c1</li></ul>', 'proper rendering after reorder'); // create the tree and make the variables available extract(create_test_tree($t, 'ioMenuItemTest')); $t->info('10 - Test copy'); check_test_tree($t, $menu); print_test_tree($t); // print the test tree $menu2 = $menu->copy(); $t->ok($menu2 !== $menu, 'menu2 is another instance then menu'); $t->ok($menu2['Parent 1'] !== $menu['Parent 1'], 'menu2->pt1 is another instance than menu->pt1'); $t->ok($menu2['Parent 1']['Child 2'] !== $menu['Parent 1']['Child 2'], 'menu2->pt1->ch2 is another instance than menu->pt1->ch2'); $t->ok($menu2['Parent 1']['Child 2']->getParent() === $menu2['Parent 1'], 'menu2->pt1->ch2->parent is same instance as menu2->pt1'); $t->ok($menu2['Parent 1']->getParent() === $menu2, 'menu2->pt1->parent is same instance as menu2'); //$t->ok($menu2['Parent 1']->getParent() !== $menu['Parent 1'], 'menu2->pt1->ch2->parent is same instance as menu->pt1'); $t->info('11 - Test slice'); $menu = new ioMenuItem('root');