Skip to content

Commit

Permalink
Fix phalcon#1608 about Phalcon\Mvc\Router\Annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
baryshev committed May 7, 2015
1 parent 6d27aab commit 344fda9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 5 additions & 1 deletion phalcon/mvc/router/annotations.zep
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 22 additions & 1 deletion unit-tests/RouterMvcAnnotationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ public function teamPostAction()

}

class MainController
{

/**
* @Get("/")
*/
public function indexAction()
{

}

}

class RouterMvcAnnotationsTest extends PHPUnit_Framework_TestCase
{
public function _getDI()
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 344fda9

Please sign in to comment.