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/4652'
Browse files Browse the repository at this point in the history
Close #4652
  • Loading branch information
Mike Willbanks committed Jun 13, 2013
2 parents ef6148c + f6b0369 commit 597a631
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 2 additions & 5 deletions library/Zend/Mvc/Service/RouterFactory.php
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/ZendTest/Mvc/Service/RouterFactoryTest.php
Expand Up @@ -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 597a631

Please sign in to comment.