public function testAdvancedMenuHandling()
 {
     // Populate from CMS Classes, check for existance of SecurityAdmin
     CMSMenu::clear_menu();
     CMSMenu::populate_menu();
     $menuItem = CMSMenu::get_menu_item('SilverStripe-Admin-SecurityAdmin');
     $this->assertInstanceOf('SilverStripe\\Admin\\CMSMenuItem', $menuItem, 'SecurityAdmin menu item exists');
     $this->assertContains($menuItem->url, SecurityAdmin::singleton()->Link(), 'Menu item has the correct link');
     $this->assertEquals($menuItem->controller, 'SilverStripe\\Admin\\SecurityAdmin', 'Menu item has the correct controller class');
     $this->assertEquals($menuItem->priority, SecurityAdmin::singleton()->stat('menu_priority'), 'Menu item has the correct priority');
     // Check that menu order is correct by priority
     // Note this will break if populate_menu includes normal links (ie, as not controller)
     $menuItems = CMSMenu::get_menu_items();
     $priority = 9999;
     // ok, *could* be set larger, but shouldn't need to be!
     foreach ($menuItems as $menuItem) {
         $this->assertEquals($menuItem->priority, singleton($menuItem->controller)->stat('menu_priority'), "Menu item {$menuItem->title} has the correct priority");
         $this->assertLessThanOrEqual($priority, $menuItem->priority, 'Menu item is of lower or equal priority');
     }
 }
 /**
  * Clear menu to default state as per LeftAndMain::init()
  */
 protected function resetMenu()
 {
     CMSMenu::clear_menu();
     CMSMenu::populate_menu();
     CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', 'Menu title'), LeftAndMain::config()->help_link, -2, array('target' => '_blank'));
 }