Skip to content

Commit

Permalink
BreadcrumbsHelper::render() returns null with no crumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
mirko-pagliai committed Nov 26, 2016
1 parent f78ed4c commit dc14d47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/View/Helper/BreadcrumbsHelper.php
Expand Up @@ -235,10 +235,14 @@ public function getCrumbs()
* - *innerAttrs* To provide attributes in case your separator is divided in two elements.
* All other properties will be converted as HTML attributes and will replace the *attrs* key in the template.
* If you use the default for this option (empty), it will not render a separator.
* @return string The breadcrumbs trail
* @return string|null The breadcrumbs trail
*/
public function render(array $attributes = [], array $separator = [])
{
if (empty($this->crumbs)) {
return null;
}

$crumbs = $this->crumbs;
$crumbsCount = count($crumbs);
$templater = $this->templater();
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase/View/Helper/BreadcrumbsHelperTest.php
Expand Up @@ -357,6 +357,8 @@ public function testInsertAfter()
*/
public function testRender()
{
$this->assertEmpty($this->breadcrumbs->render());

$this->breadcrumbs
->add('Home', '/', ['class' => 'first', 'innerAttrs' => ['data-foo' => 'bar']])
->add('Some text', ['controller' => 'tests_apps', 'action' => 'some_method'])
Expand Down

0 comments on commit dc14d47

Please sign in to comment.