From 344fda9e0117377d586beead2aed7b1c4c6f2bc5 Mon Sep 17 00:00:00 2001 From: Vadim Baryshev Date: Thu, 7 May 2015 03:02:09 +0300 Subject: [PATCH 1/2] Fix #1608 about Phalcon\Mvc\Router\Annotations --- phalcon/mvc/router/annotations.zep | 6 +++++- unit-tests/RouterMvcAnnotationsTest.php | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/phalcon/mvc/router/annotations.zep b/phalcon/mvc/router/annotations.zep index 3c06a08ff27..9286364d9ff 100644 --- a/phalcon/mvc/router/annotations.zep +++ b/phalcon/mvc/router/annotations.zep @@ -310,7 +310,11 @@ class Annotations extends Router if value != "/" { let uri = routePrefix . value; } else { - let uri = routePrefix; + if typeof routePrefix !== "null" { + let uri = routePrefix; + } else { + let uri = value; + } } } else { let uri = routePrefix . actionName; diff --git a/unit-tests/RouterMvcAnnotationsTest.php b/unit-tests/RouterMvcAnnotationsTest.php index 47dae4c9669..533d3a4cbc2 100644 --- a/unit-tests/RouterMvcAnnotationsTest.php +++ b/unit-tests/RouterMvcAnnotationsTest.php @@ -100,6 +100,19 @@ public function teamPostAction() } +class MainController +{ + + /** + * @Get("/") + */ + public function indexAction() + { + + } + +} + class RouterMvcAnnotationsTest extends PHPUnit_Framework_TestCase { public function _getDI() @@ -134,8 +147,9 @@ public function testRouterFullResources() $router->addResource('Robots'); $router->addResource('Products'); $router->addResource('About'); + $router->addResource('Main'); $router->handle(); - $this->assertEquals(count($router->getRoutes()), 8); + $this->assertEquals(count($router->getRoutes()), 9); $route = $router->getRouteByName('save-robot'); $this->assertTrue(is_object($route)); @@ -209,6 +223,13 @@ public function testRouterFullResources() 'action' => 'teampost', 'params' => array() ), + array( + 'uri' => '/', + 'method' => 'GET', + 'controller' => 'Main', + 'action' => 'index', + 'params' => array() + ), ); foreach ($routes as $route) { From 2211913540591133f8eb3ebff7d1d2fa5d8f5f10 Mon Sep 17 00:00:00 2001 From: Vadim Baryshev Date: Thu, 7 May 2015 11:30:52 +0300 Subject: [PATCH 2/2] Fix test suite --- unit-tests/RouterMvcAnnotationsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-tests/RouterMvcAnnotationsTest.php b/unit-tests/RouterMvcAnnotationsTest.php index 533d3a4cbc2..dfcc342f0c0 100644 --- a/unit-tests/RouterMvcAnnotationsTest.php +++ b/unit-tests/RouterMvcAnnotationsTest.php @@ -226,7 +226,7 @@ public function testRouterFullResources() array( 'uri' => '/', 'method' => 'GET', - 'controller' => 'Main', + 'controller' => 'main', 'action' => 'index', 'params' => array() ),