public function testHasRoleChecksMemberVariable() { $aclContainer = $this->_getAcl(); $role = $aclContainer['role']; $this->assertEquals(false, $this->_helper->hasRole()); $this->_helper->setRole($role); $this->assertEquals(true, $this->_helper->hasRole()); }
public function testLastBreadcrumbShouldBeEscaped() { $container = new Navigation(array(array('label' => 'Live & Learn', 'uri' => '#', 'active' => true))); $expected = 'Live & Learn'; $actual = $this->_helper->setMinDepth(0)->render($container); $this->assertEquals($expected, $actual); }
/** * Renders helper * * Implements {@link HelperInterface::render()}. * * @param AbstractContainer $container * [optional] container to render. Default is * to render the container registered in the helper. * @return string */ public function render($container = null) { Pi::service('log')->start('breadcrumbs'); // Try to load from cache if ($this->cache) { $cacheKey = $this->cache->key . '-bs'; $content = $this->cache->storage->getItem($cacheKey); if (null !== $content) { if (Pi::service()->hasService('log')) { Pi::service('log')->info('Breadcrumbs is loaded from cache.'); } return $content; } } // Generate if no cache available $content = parent::render($container); // Save to cache if ($this->cache) { $this->cache->storage->setItem($cacheKey, $content); } Pi::service('log')->end('breadcrumbs'); return $content; }
/** * {@inheritDoc} */ public function __toString() { try { $markup = parent::__toString(); } catch (\Exception $e) { $markup = $e->getMessage(); } return $markup; }