Example #1
0
$t->is(array(array_keys($primary->getChildren()), array_keys($secondary->getChildren())), array(array('c1', 'c2', 'c3', 'c4'), array()), 'split c4');
extract($menu->split(5));
$t->is(array(array_keys($primary->getChildren()), array_keys($secondary->getChildren())), array(array('c1', 'c2', 'c3', 'c4'), array()), 'split 5');
extract($menu->split("c5"));
$t->is(array(array_keys($primary->getChildren()), array_keys($secondary->getChildren())), array(array('c1', 'c2', 'c3', 'c4'), array()), 'split c5');
extract($menu->split(2));
$t->ok($primary['c1']->getParent() !== $secondary['c3']->getParent(), 'primary->c1 and secondary->c3 have two distinct fathers');
$t->is($primary->render(), '<ul class="menu"><li class="first">c1<ul class="menu_level_1"><li class="first">gc1</li><li class="last">gc2</li></ul></li><li class="last">c2</li></ul>', 'proper rendering of primary after slice');
$t->is($secondary->render(), '<ul class="menu"><li class="first">c3</li><li class="last">c4</li></ul>', 'proper rendering of secondary after slice');
$t->info('13 - Test menu tree property');
$menu = new ioMenuItem('root');
$menu->addChild('c1');
$menu['c1']->addChild('gc1');
$menu['c1']->addChild('gc2');
$menu->addChild('c2');
$menu->addChild('c3');
$menu->addChild('c4');
$c1 = $menu['c1'];
$t->ok($menu->getTree() === $c1->getTree(), 'root and c1 has same tree');
$menu->removeChild($c1);
$t->ok($menu->getTree() !== $c1->getTree(), 'root and c1 has different tree');
$t->ok($menu->getTree()->getRootItem() === $menu, 'root->getTree()->getRootItem() returns root');
$t->ok($c1['gc1']->getTree()->getRootItem() === $c1, 'c1[gc1]->getTree()->getRootItem() returns c1');
$menu->addChild($c1);
$t->ok($menu->getTree() === $c1->getTree(), 'root and c1 has same tree');
$t->ok($c1['gc1']->getTree()->getRootItem() === $menu, 'c1[gc1]->getTree()->getRootItem() returns root');
extract($menu->split(2));
$t->ok($primary['c2']->getTree() !== $secondary['c1']->getTree(), 'primary->c2 and secondary->c1 have two distinct trees');
// used for benchmarking
$timer->addTime();
$t->info('Test completed in ' . $timer->getElapsedTime());