From 58264e39dbf41b7795813d25d5e41827bc0e3dc8 Mon Sep 17 00:00:00 2001 From: Gregorio Chiko Putra Date: Thu, 31 Aug 2017 15:58:06 +0700 Subject: [PATCH] Modify route options and do test --- _tests/unit/RouterTest.php | 4 ++-- public/index.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_tests/unit/RouterTest.php b/_tests/unit/RouterTest.php index e8f4a3f..ffba028 100644 --- a/_tests/unit/RouterTest.php +++ b/_tests/unit/RouterTest.php @@ -24,9 +24,9 @@ class RouterTest extends \PHPUnit\Framework\TestCase ['controller' => 'posts', 'action' => 'new'] ], [ - '{controller}/{id:\d+}/{action}', + '{controller}/{action}/{id:\d+}', [], - 'posts/3/edit', + 'posts/edit/3', ['controller' => 'posts', 'action' => 'edit', 'id' => '3'] ], [ diff --git a/public/index.php b/public/index.php index 028dc42..c5cca77 100644 --- a/public/index.php +++ b/public/index.php @@ -3,7 +3,7 @@ $router = new Router(); $router->add('', ['controller' => 'Data', 'action' => 'index']); $router->add('{controller}/{action}'); -$router->add('{controller}/{id:\d+}/{action}'); +$router->add('{controller}/{action}/{id:\d+}'); $url = $_SERVER['QUERY_STRING']; $router->dispatch($url);