Skip to content

Commit

Permalink
Merge pull request #10274 from baryshev/2.0.x
Browse files Browse the repository at this point in the history
Fix #1608 about Phalcon\Mvc\Router\Annotations
  • Loading branch information
andresgutierrez committed May 9, 2015
2 parents 87aba85 + 2211913 commit 505154f
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 505154f

Please sign in to comment.