Skip to content

Commit

Permalink
Merge pull request #2332 from baryshev/patch-1
Browse files Browse the repository at this point in the history
Fix #1608 about Phalcon\Mvc\Router\Annotations
  • Loading branch information
Phalcon committed Apr 16, 2014
2 parents 8366b30 + 412db0d commit 90a8c6d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ext/mvc/router/annotations.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,11 @@ PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation){
PHALCON_INIT_VAR(uri);
PHALCON_CONCAT_VV(uri, route_prefix, value);
} else {
PHALCON_CPY_WRT(uri, route_prefix);
if (Z_TYPE_P(route_prefix) != IS_NULL) {
PHALCON_CPY_WRT(uri, route_prefix);
} else {
PHALCON_CPY_WRT(uri, value);
}
}
} else {
PHALCON_INIT_NVAR(uri);
Expand Down
23 changes: 22 additions & 1 deletion unit-tests/RouterMvcAnnotationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ public function saveAction()

}

class MainController
{

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

}

}

class RouterMvcAnnotationsTest extends PHPUnit_Framework_TestCase
{
public function _getDI()
Expand All @@ -105,10 +118,11 @@ public function testRouterFullResources()

$router->addResource('Robots');
$router->addResource('Products');
$router->addResource('Main');

$router->handle();

$this->assertEquals(count($router->getRoutes()), 7);
$this->assertEquals(count($router->getRoutes()), 8);

$route = $router->getRouteByName('save-robot');
$this->assertTrue(is_object($route));
Expand Down Expand Up @@ -175,6 +189,13 @@ public function testRouterFullResources()
'action' => 'deleteRobot',
'params' => array('id' => '100')
),
array(
'uri' => '/',
'method' => 'GET',
'controller' => 'Main',
'action' => 'index',
'params' => array()
),
);

foreach ($routes as $route) {
Expand Down

0 comments on commit 90a8c6d

Please sign in to comment.