public function testFindMultipleRoutes() { $r = new Router($this->container); $r->addRoute('a/b', 'controller1', 'action1'); $r->addRoute('a/b', 'duplicate', 'duplicate'); $r->addRoute('a', 'controller2', 'action2'); $this->assertEquals(array('controller1', 'action1'), $r->findRoute('a/b')); $this->assertEquals(array('controller2', 'action2'), $r->findRoute('a')); }
/** * Run a project */ public function run() { $cmv = array('controller' => $this->config->get('defaultController'), 'method' => $this->config->get('defaultMethod'), 'vars' => array()); $_uri = new URI(); $_uri->_fetch_uri_string(); $path = (string) $_uri; if (!empty($path)) { $founded = $this->router->findRoute($path); if (!empty($founded)) { $cmv = $founded; } else { //append uri parts as variables for method invocation $cmv['vars'] = explode('/', $path); } } //must be defined before view->render, sorry for hardcode if (DRAGON_DEBUG) { header('X-Dragon-Debug: ' . Dragon::$host . 'tmp/debug/last.html'); } //finally we have something to show $this->loadController($cmv); $this->view->render(); DebugGenerator::generate(); }