Skip to content

Commit

Permalink
Add test for urlFor with regular expressions syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
shello authored and = committed Sep 27, 2013
1 parent fd01219 commit e8d0be9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,22 @@ public function testGetMatchedRoutes()
public function testUrlFor()
{
$router = new \Slim\Router();

$route1 = new \Slim\Route('/hello/:first/:last', function () {});
$route1 = $route1->via('GET')->name('hello');
$route1 = $route1->via('GET')->name('hello');

$route2 = new \Slim\Route('/path/(:foo\.:bar)', function () {});
$route2 = $route2->via('GET')->name('regexRoute');

$routes = new \ReflectionProperty($router, 'namedRoutes');
$routes->setAccessible(true);
$routes->setValue($router, array('hello' => $route1));
$routes->setValue($router, array(
'hello' => $route1,
'regexRoute' => $route2
));

$this->assertEquals('/hello/Josh/Lockhart', $router->urlFor('hello', array('first' => 'Josh', 'last' => 'Lockhart')));
$this->assertEquals('/path/Hello.Josh', $router->urlFor('regexRoute', array('foo' => 'Hello', 'bar' => 'Josh')));
}

public function testUrlForIfNoSuchRoute()
Expand Down

0 comments on commit e8d0be9

Please sign in to comment.