From f18a57d481d91df93ac497acd6d4cacf73603c9d Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Mon, 22 Dec 2014 12:18:10 +0100 Subject: [PATCH] add failing test for generate --- tests/AltoRouterTest.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/AltoRouterTest.php b/tests/AltoRouterTest.php index 22ca703..9444549 100644 --- a/tests/AltoRouterTest.php +++ b/tests/AltoRouterTest.php @@ -233,7 +233,27 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase $this->assertEquals('/test/someaction.json', $this->router->generate('bar_route', $params)); } - + + /** + * GitHub #98 + */ + public function testGenerateWithOptionalPartOnBareUrl() + { + $this->router->map('GET', '/[i:page]?', function(){}, 'bare_route'); + + $params = array( + 'page' => 1 + ); + + $this->assertEquals('/1', + $this->router->generate('bare_route', $params)); + + $params = array(); + + $this->assertEquals('/', + $this->router->generate('bare_route', $params)); + } + public function testGenerateWithNonexistingRoute() { try{ @@ -390,9 +410,7 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase $this->assertEquals(array( 'target' => 'bare_action', - 'params' => array( - - ), + 'params' => array(), 'name' => 'bare_route' ), $this->router->match('/', 'GET')); }