Skip to content

Commit

Permalink
Merge 5649a78 into 794073a
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgsims committed May 16, 2016
2 parents 794073a + 5649a78 commit 927e901
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,40 @@ public function testCreateDispatcherReturnsSameDispatcherASecondTime()
$dispatcher2 = $method->invoke($this->router);
$this->assertSame($dispatcher2, $dispatcher);
}

/**
* @expectedException \RuntimeException
*/
public function testLookupRouteThrowsExceptionIfRouteNotFound()
{
$this->router->lookupRoute("thisIsMissing");
}

/**
* PHPUnit will convert the triggered error into a Framework error,
*
* @expectedException \PHPUnit_Framework_Error
*/
public function testUrlForTriggersError()
{
$this->router->urlFor('foo', ['name' => 'josh'], ['a' => 'b', 'c' => 'd']);
}

/**
* Test that the router urlFor will proxy into a pathFor method.
*/
public function testUrlForAliasesPathFor()
{
//create the parameters we expect
$name = 'foo';
$data = [ 'name' => 'josh' ];
$queryParams = [ 'a' => 'b', 'c' => 'd' ];

//create a router that mocks the pathFor with expected args
$router = $this->getMock('\Slim\Router', ['pathFor']);
$router->expects($this->once())->method('pathFor')->with($name, $data, $queryParams);

//suppress the error so phpunit will not convert into exception
@$router->urlFor($name, $data, $queryParams);
}
}

0 comments on commit 927e901

Please sign in to comment.