From 523d49359b9fb7b751682b449ce9974a1a38bb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Thu, 19 Jan 2017 18:40:47 +0100 Subject: [PATCH] Development - Fixed where method calling itself instead of setWhere. - Added unit-tests for regex. --- src/Pecee/SimpleRouter/Route/Route.php | 2 +- test/RouterUrlTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Pecee/SimpleRouter/Route/Route.php b/src/Pecee/SimpleRouter/Route/Route.php index 1204e6a..5e1f703 100644 --- a/src/Pecee/SimpleRouter/Route/Route.php +++ b/src/Pecee/SimpleRouter/Route/Route.php @@ -402,7 +402,7 @@ abstract class Route implements IRoute */ public function where(array $options) { - return $this->where($options); + return $this->setWhere($options); } /** diff --git a/test/RouterUrlTest.php b/test/RouterUrlTest.php index 66de841..6c2357f 100644 --- a/test/RouterUrlTest.php +++ b/test/RouterUrlTest.php @@ -99,4 +99,16 @@ class RouterUrlTest extends PHPUnit_Framework_TestCase } + public function testRegEx() + { + SimpleRouter::router()->reset(); + SimpleRouter::request()->setMethod('get'); + SimpleRouter::request()->setUri('/my/custom-path'); + + SimpleRouter::get('/my/{path}', 'DummyController@start')->where(['path' => '[a-zA-Z\-]+']); + + SimpleRouter::start(); + + } + } \ No newline at end of file