コード例 #1
0
ファイル: MenuTest.php プロジェクト: h4kuna/menu
}
Assert::equal(ACTIVE_INDEX, $_index);
/**
 * RECURSIVE RENDER ************************************************************
 * *****************************************************************************
 */
Assert::matchFile(__DIR__ . '/data/menu.html', buildHtmlRecursiveMenu($menu));
/**
 * CYCLE RENDER ****************************************************************
 * *****************************************************************************
 */
Assert::matchFile(__DIR__ . '/data/menu.html', buildHtmlCycleMenu($menu->getIndexes(), $menu));
// RecursiveTreeIterator not work for php 5.4
$tree = new RecursiveTreeIterator($menu, RecursiveTreeIterator::BYPASS_KEY | RecursiveTreeIterator::BYPASS_CURRENT);
Assert::matchFile(__DIR__ . '/data/menu.html', buildHtmlCycleMenu($tree, $menu));
/**
 * HIDE ITEM *******************************************************************
 * *****************************************************************************
 */
$_items = $items;
$_items[0]['hide'] = TRUE;
$menuHide = Menu\MenuFactory::createFromArray($_items);
Assert::matchFile(__DIR__ . '/data/menu-hide.html', buildHtmlRecursiveMenu($menuHide));
/**
 * SQL STRUCTURE ***************************************************************
 * *****************************************************************************
 */
$sqlMenu = Menu\MenuFactory::createFromSql(Transform::array2sql($menu));
$sqlMenu->setActiveItem(Transform::getId(ACTIVE_INDEX));
Assert::matchFile(__DIR__ . '/data/menu.html', buildHtmlRecursiveMenu($sqlMenu));
echo 'ok';