/** * @runInSeparateProcess */ public function testCase008() { $router = new Yaf_Router(); $route = new Yaf_Route_Simple('m', 'c', 'a'); $sroute = new Yaf_Route_Supervar('r'); $router->addRoute("simple", $route)->addRoute("super", $sroute); $routes = $router->getRoutes(); $this->assertEquals(3, count($routes)); $this->assertSame($route, $routes['simple']); $this->assertSame($sroute, $routes['super']); $this->assertNull($router->getCurrentRoute()); $this->assertSame($route, $router->getRoute('simple')); $this->assertNull($router->getRoute('noexists')); }
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); }
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)); }