示例#1
0
 public function testRewriteInstanceConfig()
 {
     $config = new Yaf_Config_Ini("framework/Yaf/_files/route_rewrite.ini");
     $this->router->addConfig($config->production->routes);
     $this->request->setRequestUri('/product/test/14');
     $return = $this->router->route($this->request);
     $currentRouteName = $this->router->getCurrentRoute();
     $this->assertEquals('route_name1', $currentRouteName);
     $currentRoute = $this->router->getRoute($currentRouteName);
     $this->assertInstanceOf('Yaf_Route_Rewrite', $currentRoute);
     $this->assertEquals(null, $this->request->getModuleName());
     $this->assertEquals('product', $this->request->getControllerName());
     $this->assertEquals('info', $this->request->getActionName());
     $params = $this->request->getParams();
     $this->assertTrue(is_array($params));
     $this->assertEquals(array("name" => "test", "value" => "14"), $params);
 }
示例#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));
 }
示例#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"));
 }