/** * Widget's run method */ public function run() { $this->tabs = $this->normalizeTabs($this->tabs); echo TbHtml::tabbable($this->type, $this->tabs, $this->htmlOptions); $this->registerClientScript(); }
public function testTabbable() { $I = $this->codeGuy; $tabs = array(array('label' => 'Home', 'content' => 'Tab content', 'active' => true), array('label' => 'Profile', 'content' => 'Tab content', 'id' => 'profile'), array('label' => 'Messages', 'items' => array(array('label' => '@fat', 'content' => 'Tab content'), array('label' => '@mdo', 'content' => 'Tab content')))); $html = TbHtml::tabbable(TbHtml::NAV_TYPE_NONE, $tabs, array('class' => 'div')); $tabbable = $I->createNode($html, 'div.tabbable'); $I->seeNodeCssClass($tabbable, 'div'); $ul = $tabbable->filter('ul.nav'); $I->seeNodeNumChildren($ul, 3); foreach ($ul->children() as $i => $liElement) { $li = $I->createNode($liElement); if ($i === 0) { $I->seeNodeCssClass($li, 'active'); } if ($i === 2) { $I->seeNodeCssClass($li, 'dropdown'); $a = $li->filter('a.dropdown-toggle'); $I->seeNodeText($a, 'Messages'); $subUl = $li->filter('ul.dropdown-menu'); foreach ($subUl->children() as $j => $subLiElement) { $subLi = $I->createNode($subLiElement); $subA = $subLi->filter('a'); $I->seeNodeAttributes($subA, array('data-toggle' => 'tab', 'tabindex' => '-1', 'href' => '#tab_' . ($i + $j + 1))); $I->seeNodeText($subA, $tabs[$i]['items'][$j]['label']); } } else { $a = $li->filter('a'); $I->seeNodeAttributes($a, array('data-toggle' => 'tab', 'tabindex' => '-1', 'href' => '#' . (isset($tabs[$i]['id']) ? $tabs[$i]['id'] : 'tab_' . ($i + 1)))); $I->seeNodeText($a, $tabs[$i]['label']); } } $content = $tabbable->filter('div.tab-content'); $I->seeNodeNumChildren($content, 4); foreach ($content->children() as $i => $paneElement) { $pane = $I->createNode($paneElement); $I->seeNodeCssClass($pane, 'tab-pane fade'); if ($i === 0) { $I->seeNodeCssClass($pane, 'active in'); } if ($i > 1) { $I->seeNodeText($pane, $tabs[2]['items'][$i - 2]['content']); } else { $I->seeNodeText($pane, $tabs[$i]['content']); } } }