/** * testClass * * @since 2.2.0 * * @param array $className * @param string $expect * * @dataProvider providerClass */ public function testClass($className = array(), $expect = null) { /* setup */ $element = new Element('a'); /* actual */ $actual = $element->addClass($className[0])->removeClass($className[1])->render(); /* compare */ $this->assertEquals($expect, $actual); }
/** * render the breadcrumb trail as an unordered list * * @since 2.1.0 * * @return string */ public function render() { $output = Hook::trigger('breadcrumb_start'); $outputItem = ''; /* breadcrumb keys */ $breadcrumbKeys = array_keys($this->_breadcrumbArray); $lastKey = end($breadcrumbKeys); /* html elements */ $linkElement = new Element('a'); $itemElement = new Element('li'); $listElement = new Element('ul', array('class' => $this->_options['className']['list'])); /* collect item output */ foreach ($this->_breadcrumbArray as $key => $value) { $title = array_key_exists('title', $value) ? $value['title'] : null; $route = array_key_exists('route', $value) ? $value['route'] : null; if ($title) { $outputItem .= '<li>'; /* build link if route */ if ($route) { $outputItem .= $linkElement->attr(array('href' => $this->_registry->get('rewriteRoute') . $route, 'title' => $title))->text($title); } else { $outputItem .= $title; } $outputItem .= '</li>'; /* add divider */ if ($key !== $lastKey) { $outputItem .= $itemElement->addClass($this->_options['className']['divider'])->text(Db::getSettings('divider')); } } } /* collect list output */ if ($outputItem) { $output = $listElement->html($outputItem); } $output .= Hook::trigger('breadcrumb_end'); return $output; }