/**
  * Test the configuration reader.
  *
  * @cover NavbarService::parseConfiguration()
  * @cover NavbarService::parseMenuConfiguration()
  * @cover NavbarService::parseNavbarListConfiguration()
  * @cover NavbarService::parseNavbarConfiguration()
  */
 public function testConfigurationReader()
 {
     $navbarService = new NavbarService();
     $configuration = self::getConfigurationExample();
     $navbarService->parseConfiguration($configuration);
     $this->assertEquals(2, count($navbarService->getNavbars()));
     foreach ($configuration['menu']['_menus'] as $navbar_cfg) {
         $navbar = $navbarService->getNavbar($navbar_cfg['index']);
         $this->assertTrue($navbar instanceof Navbar);
         $menus_flat = array();
         foreach ($navbar_cfg['content'] as $menu_cfg) {
             $menu = new Menu();
             $menu->setTitle($menu_cfg['title']);
             $menu->setLink($menu_cfg['route']);
             $menus_flat[$menu_cfg['id']] = $menu;
         }
         $menu_list = array();
         foreach ($navbar_cfg['content'] as $menu_cfg) {
             if ($menu_cfg['parent_id'] > 0) {
                 $menus_flat[$menu_cfg['parent_id']]->pushSubmenu($menus_flat[$menu_cfg['id']]);
             } else {
                 $menu_list[] = $menus_flat[$menu_cfg['id']];
             }
         }
         $this->assertEquals($menu_list, $navbar->getMenuList());
     }
     // Test with url generator
     $navbarService = new NavbarService($this->urlGenerator);
     $tstFakeRoot = 'test-route-' . uniqid();
     $navbarService->parseConfiguration(array('menu' => array('_menus' => array(array('index' => 'test', 'content' => array(array('id' => 1, 'parent_id' => 0, 'title' => 'test menu 1 1 ' . uniqid(), 'route' => 'bootstrap-bundle-test-route'), array('id' => 2, 'parent_id' => 0, 'title' => 'test menu 1 2 ' . uniqid(), 'route' => $tstFakeRoot)))))));
     $navbar = $navbarService->getNavbar('test');
     $menuList = $navbar->getMenuList();
     $this->assertEquals('/this/is/a/test', $menuList[0]->getLink());
     $this->assertEquals($tstFakeRoot, $menuList[1]->getLink());
 }
 /**
  * Get the rendered navbar
  *
  * @param string $menu_title The title of the used menu
  * @return string
  */
 public function navbarRender($menu_title = null)
 {
     $this->navbarService->parseConfiguration($this->configuration);
     $navbar = $this->navbarService->getNavbar($menu_title);
     return $this->environment->render($this->getTemplateName(), array('menu_list' => $navbar ? $navbar->getMenuList() : array(), 'cfg' => $this->configuration));
 }