Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/namespaceroute-controller-name' of https://githu…
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jul 23, 2012
2 parents d937e7f + 6190cb0 commit 400808e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Mvc/ModuleRouteListener.php
Expand Up @@ -94,7 +94,7 @@ public function onRoute($e)

// Prepend the controllername with the module, and replace it in the
// matches
$controller = $module . '\\' . $controller;
$controller = $module . '\\' . str_replace(' ', '', ucwords(str_replace('-', ' ', $controller)));
$matches->setParam('controller', $controller);
}
}
28 changes: 28 additions & 0 deletions tests/Zend/Mvc/ModuleRouteListenerTest.php
Expand Up @@ -104,4 +104,32 @@ public function testMultipleRegistrationShouldNotResultInMultiplePrefixingOfCont
$this->assertEquals('Foo\Index', $matches->getParam('controller'));
$this->assertEquals('Index', $matches->getParam(ModuleRouteListener::ORIGINAL_CONTROLLER));
}

public function testRouteMatchIsTransformedToProperControllerClassName()
{
$moduleListener = new ModuleRouteListener();
$this->events->attach($moduleListener);

$this->router->addRoute('foo', array(
'type' => 'Literal',
'options' => array(
'route' => '/foo',
'defaults' => array(
ModuleRouteListener::MODULE_NAMESPACE => 'Foo',
'controller' => 'some-index',
),
),
));

$this->request->setUri('/foo');
$event = new MvcEvent();
$event->setRouter($this->router);
$event->setRequest($this->request);
$this->events->trigger('route', $event);

$matches = $event->getRouteMatch();
$this->assertInstanceOf('Zend\Mvc\Router\RouteMatch', $matches);
$this->assertEquals('Foo\SomeIndex', $matches->getParam('controller'));
$this->assertEquals('some-index', $matches->getParam(ModuleRouteListener::ORIGINAL_CONTROLLER));
}
}

0 comments on commit 400808e

Please sign in to comment.