Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

fixes #39 Throw correct exception object on invalid parameter passed … #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Page/Mvc.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public function getRouteMatch()
public function setRouteMatch($matches)
{
if (! $matches instanceof RouteMatch && ! $matches instanceof MvcRouter\RouteMatch) {
throw new InvalidArgumentException(sprintf(
throw new Exception\InvalidArgumentException(sprintf(
'RouteMatch passed to %s must be either a %s or a %s instance; received %s',
__METHOD__,
RouteMatch::class,
Expand Down
10 changes: 10 additions & 0 deletions test/Page/MvcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Zend\Mvc\MvcEvent;
use Zend\Mvc\Router as MvcRouter;
use Zend\Navigation\Page;
use Zend\Navigation\Exception;
use Zend\Navigation;
use Zend\Router\Http\Literal as LiteralRoute;
use Zend\Router\Http\Regex as RegexRoute;
Expand Down Expand Up @@ -782,4 +783,13 @@ public function testRecursiveDetectIsActiveWhenRouteNameIsKnown()
$this->assertTrue($childPage->isActive(true));
$this->assertTrue($parentPage->isActive(true));
}

public function testSetRouteMatchThrowsExceptionOnInvalidParameter()
{
$this->setExpectedException(Exception\InvalidArgumentException::class);

$page = new Page\Mvc();
$page->setRouter($this->getRouterClass());
$page->setRouteMatch(null);
}
}