From e72248c744bf8824eada9fd07860ebdebe820760 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Mon, 22 Dec 2014 12:10:34 +0100 Subject: [PATCH] add failing test for #98 --- tests/AltoRouterTest.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/AltoRouterTest.php b/tests/AltoRouterTest.php index 2a9160c..22ca703 100644 --- a/tests/AltoRouterTest.php +++ b/tests/AltoRouterTest.php @@ -364,6 +364,37 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase 'name' => 'bar_route' ), $this->router->match('/bar/test/do.json', 'GET')); + $this->assertEquals(array( + 'target' => 'bar_action', + 'params' => array( + 'controller' => 'test', + 'action' => 'do' + ), + 'name' => 'bar_route' + ), $this->router->match('/bar/test/do', 'GET')); + } + + /** + * GitHub #98 + */ + public function testMatchWithOptionalPartOnBareUrl(){ + $this->router->map('GET', '/[i:page]?', 'bare_action', 'bare_route'); + + $this->assertEquals(array( + 'target' => 'bare_action', + 'params' => array( + 'page' => 1 + ), + 'name' => 'bare_route' + ), $this->router->match('/1', 'GET')); + + $this->assertEquals(array( + 'target' => 'bare_action', + 'params' => array( + + ), + 'name' => 'bare_route' + ), $this->router->match('/', 'GET')); } public function testMatchWithWildcard()