Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #218 from sebastianblum/master
Browse files Browse the repository at this point in the history
Required Menu Bundle
  • Loading branch information
dbu committed Jan 22, 2015
2 parents aa78e0d + 9c22f06 commit f0e6a93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Doctrine/Phpcr/MenuBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ public function getMenuNode()
*
* Set to null to remove the reference.
*
* @param NodeInterface $menuNode A mapped menu node.
* @param NodeInterface|null $menuNode A mapped menu node.
*
* @return MenuBlock $this
*/
public function setMenuNode(NodeInterface $menuNode = null)
public function setMenuNode($menuNode = null)
{
$this->menuNode = $menuNode;
if (null === $menuNode || $menuNode instanceof NodeInterface) {
$this->menuNode = $menuNode;
} else {
throw new \InvalidArgumentException('$menuNode must be an instane of NodeInterface');
}

return $this;
}
Expand Down
12 changes: 12 additions & 0 deletions Tests/Functional/Block/MenuBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ public function testExecutionOfEnabledBlock()
$menuBlockService = new MenuBlockService('test-service', $templatingMock, $blockRendererMock, $blockContextManagerMock);
$menuBlockService->execute($menuBlockContext);
}

public function testSetMenuNode()
{
$menuBlock = new MenuBlock();
$this->assertAttributeEmpty('menuNode', $menuBlock);

$menuBlock->setMenuNode($this->getMock('Knp\Menu\NodeInterface'));
$this->assertAttributeInstanceOf('Knp\Menu\NodeInterface', 'menuNode', $menuBlock);

$menuBlock->setMenuNode(null);
$this->assertAttributeSame(null, 'menuNode', $menuBlock);
}
}

0 comments on commit f0e6a93

Please sign in to comment.