Permalink
Browse files

router defaults not being set properly in console

The router defaults were not being set correctly when the
"console.router" config was not present.
  • Loading branch information...
1 parent da88f95 commit 3558ec996e0fad1343fdebd01be9de2bdd7dcdc5 @radnan committed Jun 13, 2013
Showing with 14 additions and 5 deletions.
  1. +2 −5 library/Zend/Mvc/Service/RouterFactory.php
  2. +12 −0 tests/ZendTest/Mvc/Service/RouterFactoryTest.php
@@ -41,12 +41,9 @@ public function createService(ServiceLocatorInterface $serviceLocator, $cName =
if ($rName === 'ConsoleRouter' // force console router
|| ($cName === 'router' && Console::isConsole()) // auto detect console
) {
- // We are in a console, use console router.
- if (isset($config['console']) && isset($config['console']['router'])) {
- $routerConfig = $config['console']['router'];
- }
-
+ // We are in a console, use console router defaults.
$routerClass = 'Zend\Mvc\Router\Console\SimpleRouteStack';
+ $routerConfig = isset($config['console']['router']) ? $config['console']['router'] : array();
}
// Obtain the configured router class, if any
@@ -41,4 +41,16 @@ public function testFactoryCanCreateRouterBasedOnConfiguredName()
$router = $this->factory->createService($this->services, 'router', 'Router');
$this->assertInstanceOf('ZendTest\Mvc\Service\TestAsset\Router', $router);
}
+
+ public function testFactoryCanCreateRouterWhenOnlyHttpRouterConfigPresent()
+ {
+ $this->services->setService('Config', array(
+ 'router' => array(
+ 'router_class' => 'ZendTest\Mvc\Service\TestAsset\Router',
+ ),
+ ));
+
+ $router = $this->factory->createService($this->services, 'router', 'Router');
+ $this->assertInstanceOf('Zend\Mvc\Router\Console\SimpleRouteStack', $router);
+ }
}

0 comments on commit 3558ec9

Please sign in to comment.