Пример #1
0
 public function testMapRouterViaConfig()
 {
     $router = new Yaf_Router();
     $config = array("name" => array("type" => "map", "controllerPrefer" => false, "delimiter" => "#!"));
     $router->addConfig(new Yaf_Config_Simple($config));
     $request = new Yaf_Request_Http('/user/list/#!/foo/22', '/');
     $router->route($request);
     $this->assertEquals(null, $request->getModuleName());
     $this->assertEquals('user_list', $request->getActionName());
     $this->assertEquals(null, $request->getControllerName());
     $params = $request->getParams();
     $this->assertEquals(array('foo' => '22'), $params);
 }
Пример #2
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);
 }
Пример #3
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));
 }