/** * */ public function testInit() { Request::set('controller', ''); Request::set('action', ''); $router = Router::getInstance(); $this->assertEquals('This is the base controller and the default action', $router->init()); }
/** * Initializing router * * @return mixed */ public function init() { $controller = String::upperFirst(strtolower(Request::get('controller'))); $action = String::lower(Request::get('action')) . 'Action'; $controllerData = ClassHandler::loadController($controller, $action); $controller = new $controllerData['controller'](); if (method_exists($controller, 'init')) { call_user_func(array($controller, 'init')); } return call_user_func(array($controller, $controllerData['action'])); }
/** * Initialize requests * * @return void */ private function initRequest() { $request = new Command(); /** @noinspection PhpParamsInspection */ $request->add(Get::getInstance()); /** @noinspection PhpParamsInspection */ $request->add(Post::getInstance()); /** @noinspection PhpParamsInspection */ $request->add(Cookie::getInstance()); /** @noinspection PhpParamsInspection */ $request->add(Request::getInstance()); $request->run(); }
/** * */ public function testHas() { $this->assertTrue(Request::has('abc')); $this->assertFalse(Request::has('xyz')); }