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..dfcc342f0c0 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) {