示例#1
0
 /**
  *
  */
 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());
 }
示例#2
0
 /**
  * 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']));
 }
示例#3
0
 /**
  * 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();
 }
示例#4
0
 /**
  *
  */
 public function testHas()
 {
     $this->assertTrue(Request::has('abc'));
     $this->assertFalse(Request::has('xyz'));
 }