function testController() { copy(SITE_PATH . "tests/fixtures/controller_routes.fixture.php", SITE_PATH . "config/_routes.php"); # test connect $request = load_egg("request", 1); $request->uri_parts = explode("/", "test/25/delete"); $request->request_method = "post"; $routing = new Routing($request, "_routes"); $request_info = $routing->climb(); $request->request_info = $request_info; $controller = new Controller(); $controller->load($request); unlink(SITE_PATH . "config/_routes.php"); unlink(SITE_PATH . "config/_routes.tmp.php"); }
function testController() { copy(SITE_PATH . "tests/fixtures/controller_routes.fixture.php", SITE_PATH . "config/_routes.php"); # test connect $request = load_egg("request", 1); $request->uri_parts = explode("/", "testz/25/delete"); $request->request_method = "post"; $routing = new Routing($request, "_routes"); $request_info = $routing->climb(); $request->request_info = $request_info; $controller = new Controller(); ob_start(); $controller->load($request); $output = ob_get_contents(); ob_end_clean(); $this->assertEqual($output, "Hello World"); unlink(SITE_PATH . "config/_routes.php"); unlink(SITE_PATH . "config/_routes.tmp.php"); }
function testRoutingRealWorldUsage() { copy(SITE_PATH . "tests/fixtures/routes.fixture.php", SITE_PATH . "config/test_routes.php"); # test connect $request = new Request(); $request->uri_parts = explode("/", "login/25/dude"); $request->request_method = "get"; $routing = new Routing($request, "test_routes"); $request_info = $routing->climb(); $keys = array_keys($request_info["param"]); $this->assertEqual($keys[0], "altceva"); unset($routing); # test resources $request = new Request(); $request->uri_parts = explode("/", "teams/25/edit"); $request->request_method = "get"; $routing = new Routing($request, "test_routes"); $request_info = $routing->climb(); $this->assertEqual($request_info["action"], "edit"); unlink(SITE_PATH . "config/test_routes.php"); unlink(SITE_PATH . "config/test_routes.tmp.php"); }