Skip to content

Commit

Permalink
Update the tests for the exception of insertAt()
Browse files Browse the repository at this point in the history
  • Loading branch information
HavokInspiration committed Oct 13, 2016
1 parent f565b5b commit 96145fa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/View/Helper/BreadcrumbsHelper.php
Expand Up @@ -194,7 +194,7 @@ public function insertAfter($matchingTitle, $title, $url = null, array $options
throw new LogicException(sprintf("No crumb matching '%s' could be found.", $matchingTitle));
}

return $this->insertAt($key, $title, $url, $options);
return $this->insertAt($key + 1, $title, $url, $options);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions tests/TestCase/View/Helper/BreadcrumbsHelperTest.php
Expand Up @@ -42,6 +42,7 @@ public function setUp()

/**
* Test adding crumbs to the trail using add()
*
* @return void
*/
public function testAdd()
Expand Down Expand Up @@ -74,6 +75,7 @@ public function testAdd()

/**
* Test adding multiple crumbs at once to the trail using add()
*
* @return void
*/
public function testAddMultiple()
Expand Down Expand Up @@ -122,6 +124,7 @@ public function testAddMultiple()

/**
* Test adding crumbs to the trail using prepend()
*
* @return void
*/
public function testPrepend()
Expand Down Expand Up @@ -159,6 +162,7 @@ public function testPrepend()

/**
* Test adding crumbs to a specific index
*
* @return void
*/
public function testInsertAt()
Expand Down Expand Up @@ -206,8 +210,21 @@ public function testInsertAt()
$this->assertEquals($expected, $result);
}

/**
* Test adding crumbs to a specific index
*
* @expectedException \LogicException
*/
public function testInsertAtIndexOutOfBounds()
{
$this->breadcrumbs
->add('Home', '/', ['class' => 'first'])
->insertAt(2, 'Insert At Again', ['controller' => 'Insert', 'action' => 'at_again']);
}

/**
* Test adding crumbs before a specific one
*
* @return void
*/
public function testInsertBefore()
Expand Down Expand Up @@ -251,6 +268,7 @@ public function testInsertBefore()

/**
* Test adding crumbs after a specific one
*
* @return void
*/
public function testInsertAfter()
Expand Down Expand Up @@ -294,6 +312,7 @@ public function testInsertAfter()

/**
* Tests the render method
*
* @return void
*/
public function testRender()
Expand Down Expand Up @@ -343,6 +362,7 @@ public function testRender()

/**
* Tests the render method with custom templates
*
* @return void
*/
public function testRenderCustomTemplate()
Expand Down Expand Up @@ -383,6 +403,7 @@ public function testRenderCustomTemplate()

/**
* Tests the render method with template vars
*
* @return void
*/
public function testRenderCustomTemplateTemplateVars()
Expand Down

0 comments on commit 96145fa

Please sign in to comment.