Exemplo n.º 1
0
 public function testConfigChaining()
 {
     $routes = array('www' => array('type' => 'Zend\\Controller\\Router\\Route\\Hostname', 'route' => 'www.example.com', 'abstract' => true), 'user' => array('type' => 'Zend\\Controller\\Router\\Route\\Hostname', 'route' => 'user.example.com', 'abstract' => true), 'index' => array('type' => 'Zend\\Controller\\Router\\Route\\StaticRoute', 'route' => '', 'abstract' => true, 'defaults' => array('module' => 'default', 'controller' => 'index', 'action' => 'index')), 'imprint' => array('type' => 'Zend\\Controller\\Router\\Route\\StaticRoute', 'route' => 'imprint', 'abstract' => true, 'defaults' => array('module' => 'default', 'controller' => 'index', 'action' => 'imprint')), 'profile' => array('type' => 'Zend\\Controller\\Router\\Route\\StaticRoute', 'route' => 'profile', 'abstract' => true, 'defaults' => array('module' => 'user', 'controller' => 'profile', 'action' => 'index')), 'profile-edit' => array('type' => 'Zend\\Controller\\Router\\Route\\StaticRoute', 'route' => 'profile/edit', 'abstract' => true, 'defaults' => array('module' => 'user', 'controller' => 'profile', 'action' => 'edit')), 'www-index' => array('type' => 'Zend\\Controller\\Router\\Route\\Chain', 'chain' => 'www, index'), 'www-imprint' => array('type' => 'Zend\\Controller\\Router\\Route\\Chain', 'chain' => 'www, imprint'), 'user-index' => array('type' => 'Zend\\Controller\\Router\\Route\\Chain', 'chain' => 'user, index'), 'user-profile' => array('type' => 'Zend\\Controller\\Router\\Route\\Chain', 'chain' => 'user, profile'), 'user-profile-edit' => array('type' => 'Zend\\Controller\\Router\\Route\\Chain', 'chain' => 'user, profile-edit'));
     $router = new Router\Rewrite();
     $front = Controller\Front::getInstance();
     $front->resetInstance();
     $front->setDispatcher(new Dispatcher());
     $front->setRequest(new Request());
     $router->setFrontController($front);
     $router->addConfig(new Config\Config($routes));
     $request = new Request('http://user.example.com/profile');
     $token = $router->route($request);
     $this->assertEquals('user', $token->getModuleName());
     $this->assertEquals('profile', $token->getControllerName());
     $this->assertEquals('index', $token->getActionName());
     $request = new Request('http://foo.example.com/imprint');
     $token = $router->route($request);
     $this->assertEquals('default', $token->getModuleName());
     $this->assertEquals('imprint', $token->getControllerName());
     $this->assertEquals('defact', $token->getActionName());
 }