Exemplo n.º 1
0
 function testDispatchWithOffset()
 {
     $config_array = array(array('path' => ':controller/:action'));
     $routes = new lmbRoutes($config_array);
     $this->toolkit->setRoutes($routes);
     $dispatcher = new lmbRoutesRequestDispatcher($path_offset = '/www', $base_path = 'http://example.com/app/');
     $this->request->getUri()->reset('http://example.com/app/news/admin_display');
     $result = $dispatcher->dispatch($this->request);
     $this->assertEqual($result['controller'], 'news');
     $this->assertEqual($result['action'], 'admin_display');
 }
 function testDispatcherFoundRoute()
 {
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $this->request = new HttpRequest();
     $this->toolkit->setRequest($this->request);
     $config_array = array(array('path' => '/blog/:action', 'defaults' => array('controller' => 'blog', 'action' => 'display'), 'request_method' => 'GET'), array('path' => '/blog/:action', 'defaults' => array('controller' => 'blog', 'action' => 'save'), 'request_method' => 'POST'));
     $routes = new lmbRoutes($config_array);
     $this->toolkit->setRoutes($routes);
     $this->request->getUri()->reset('/blog');
     $dispatcher = new lmbRoutesRequestDispatcher();
     $result = $dispatcher->dispatch($this->request);
     $this->assertEqual($result['controller'], 'blog');
     $this->assertEqual($result['action'], 'save');
 }
 function testDispatchWithOffset()
 {
     $old_offset = lmb_env_get('LIMB_HTTP_OFFSET_PATH');
     $config_array = array(array('path' => ':controller/:action'));
     $routes = new lmbRoutes($config_array);
     $this->toolkit->setRoutes($routes);
     $dispatcher = new lmbRoutesRequestDispatcher();
     lmb_env_set('LIMB_HTTP_OFFSET_PATH', 'app');
     $this->request->getUri()->reset('http://example.com/app/news/admin_display');
     $result = $dispatcher->dispatch($this->request);
     $this->assertEqual($result['controller'], 'news');
     $this->assertEqual($result['action'], 'admin_display');
     lmb_env_set('LIMB_HTTP_OFFSET_PATH', $old_offset);
 }