Exemple #1
0
 public function testCase011()
 {
     $this->request->setRequestUri('/subdir/ap/1.2/name/value');
     $this->request->setBaseUri('/subdir');
     $route = new Yaf_Route_Rewrite("/subdir/:name/:version", array("action" => "version"));
     $this->router->addRoute("subdir", $route)->addRoute("ap", new Yaf_Route_Rewrite("/ap/:version/*", array("action" => 'ap')))->route($this->request);
     $this->assertEquals('ap', $this->router->getCurrentRoute());
     $this->assertEquals('1.2', $this->request->getParam('version'));
     $this->assertEquals('ap', $this->request->getActionName());
     $this->assertEquals(null, $this->request->getControllerName());
     $this->assertEquals('value', $this->request->getParam('name'));
 }
Exemple #2
0
 public function testSimpleInstanceConfig()
 {
     if (defined('YAF_MODE')) {
         $this->markTestSkipped('Yaf_Route_Simple does not allow to change the get');
         return;
     }
     $_GET['module'] = 'Foo';
     $_GET['controller'] = 'contr';
     $_GET['action'] = 'action';
     $config = new Yaf_Config_Ini("framework/Yaf/_files/route_simple.ini");
     $this->router->addConfig($config->production->routes);
     $this->request->setRequestUri('/');
     $this->request->setBaseUri('/');
     $return = $this->router->route($this->request);
     $currentRouteName = $this->router->getCurrentRoute();
     $this->assertEquals('route_name1', $currentRouteName);
     $currentRoute = $this->router->getRoute($currentRouteName);
     $this->assertInstanceOf('Yaf_Route_Simple', $currentRoute);
     $this->assertEquals('Foo', $this->request->getModuleName());
     $this->assertEquals('contr', $this->request->getControllerName());
     $this->assertEquals('action', $this->request->getActionName());
     $params = $this->request->getParams();
     $this->assertTrue(empty($params));
 }
Exemple #3
0
 public function testCase019()
 {
     $request = new Yaf_Request_Http("/subdir/ap/1.2/name/value", "/subdir");
     $router = new Yaf_Router();
     $router->addConfig(array(array("type" => "regex", "match" => "#^/ap/([^/]*)/*#i", "route" => array(array("action" => 'ap')), "map" => array(1 => 'version'))))->route($request);
     $this->assertEquals(0, $router->getCurrentRoute());
     $this->assertEquals('1.2', $request->getParam("version"));
 }