my app/config/router.php
<?php
$router = $di->get("router");
foreach ($application->getModules() as $key => $module) { $namespace = str_replace('Module','Controllers', $module["className"]); $router->add('/'.$key.'/:params', [ 'namespace' => $namespace, 'module' => $key, 'controller' => 'index', 'action' => 'index', 'params' => 1 ])->setName($key); $router->add('/'.$key.'/:controller/:params', [ 'namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 'index', 'params' => 2 ]); $router->add('/'.$key.'/:controller/:action/:params', [ 'namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 2, 'params' => 3 ]); }
$di->set("router", $router);
my codecept test function
public function openIndexInfoByRoute(FunctionalTester $I)
{
$I->amOnRoute('frontend.index.info');
$I->see('phpinfo');
}
error info
[Phalcon\Mvc\Url\Exception] Cannot obtain a route using the name 'frontend.index.info'