Esempio n. 1
0
 /**
  * Get the current sfSympalMenuItem instance for this sympal context
  *
  * @return sfSympalMenuItem
  */
 public function getCurrentMenuItem()
 {
     if (!$this->_currentMenuItem) {
         $this->_currentMenuItem = sfSympalMenuSiteManager::getInstance()->findCurrentMenuItem();
     }
     return $this->_currentMenuItem;
 }
Esempio n. 2
0
$total = $primaryMenu->count();
$t->is($split['primary']->count(), 2, 'Test count() after splitting the menu into 2 pieces');
$t->is((string) $split['primary'], '<ul id="primary-menu"><li id="primary-blog" class="first">Blog</li><li id="primary-signout">Signout</li></ul>', 'Test split() primary');
$t->is((string) $split['secondary'], '<ul id="secondary-menu"><li id="primary-home">Home</li><li id="primary-sample-page">Sample Page</li><li id="primary-sample-content-list">Sample Content List</li><li id="primary-powered-by" class="last">Powered By</li></ul>', 'Test split() secondary');
$t->is($split['secondary']->count(), 4, 'Test secondary count()');
$footerMenu = $manager->getMenu('footer', false, 'sfSympalMenuSiteTest');
$t->is((string) $footerMenu, '', 'Test footer menu');
$table = Doctrine_Core::getTable('sfSympalMenuItem');
$menuItems = $table->createQuery('m')->execute();
$menuItem = $table->createQuery('m')->where('m.slug = ?', 'home')->fetchOne();
$t->is($menuItem->getIndentedName(), '- Home', 'Test sfSympalMenuItem::getIndentedName()');
$t->is((string) $menuItem, '- Home', 'Test sfSympalMenuItem::__toString()');
$t->is($menuItem->getContent()->getHeaderTitle(), 'Home', 'Test sfSympalMenuItem::getHeaderTitle()');
$t->is($menuItem->getLabel(), 'Home', 'Test sfSympalMenuItem::getLabel()');
$t->is($menuItem->getItemRoute(), '@sympal_content_home', 'Test sfSympalMenuItem::getItemRoute()');
$t->is($menuItem->getBreadcrumbs()->getPathAsString(), '', 'Test sfSympalBreadcrumbs::getPathAsString() returns nothing for home');
$menuItem = $table->createQuery('m')->where('m.slug = ?', 'sample-page')->fetchOne();
$t->is($menuItem->getBreadcrumbs()->getPathAsString(), 'Home / Sample Page', 'Test sfSympalBreadcrumbs::getPathAsString() returns nothing for home');
$menuManager = sfSympalMenuSiteManager::getInstance();
$menuManager->clear();
$profiler = new Doctrine_Connection_Profiler();
$conn = Doctrine_Manager::connection();
$conn->addListener($profiler);
$menuManager->initialize();
$count = 0;
foreach ($profiler as $event) {
    if ($event->getName() == 'execute') {
        $count++;
    }
}
$t->is($count, 1, 'Test menus do not require more than one query');