Skip to content
Permalink
Browse files

Add reset method to BreadcrumbsHelper

  • Loading branch information...
coryjthompson committed Jan 22, 2017
1 parent ffcd5f5 commit e49d0957c0dea380f2fe57c98f6f9a1ef45cd5e4
Showing with 30 additions and 0 deletions.
  1. +12 −0 src/View/Helper/BreadcrumbsHelper.php
  2. +18 −0 tests/TestCase/View/Helper/BreadcrumbsHelperTest.php
@@ -223,6 +223,18 @@ public function getCrumbs()
return $this->crumbs;
}
/**
* Removes all existing crumbs.
*
* @return $this
*/
public function reset()
{
$this->crumbs = [];
return $this;
}
/**
* Renders the breadcrumbs trail.
*
@@ -200,6 +200,24 @@ public function testPrependMultiple()
$this->assertEquals($expected, $result);
}
/**
* Test ability to empty crumbs list.
*
* @return void
*/
public function testReset()
{
$this->breadcrumbs->add('Home', '/');
$this->breadcrumbs->add('Products', '/products');
$crumbs = $this->breadcrumbs->getCrumbs();
$this->assertEquals(count($crumbs), 2);
$this->breadcrumbs->reset();
$actual = $this->breadcrumbs->getCrumbs();
$this->assertEquals($actual, []);
}
/**
* Test adding crumbs to a specific index
*

0 comments on commit e49d095

Please sign in to comment.
You can’t perform that action at this time.