Пример #1
0
 /**
  * @covers Starlit\App\Provider\ErrorServiceProvider::register
  * @covers Starlit\App\Provider\StandardServiceProvider::register
  * @covers Starlit\App\BaseApp::getSession
  */
 public function testInit()
 {
     $this->assertInstanceOf('\\Symfony\\Component\\HttpFoundation\\Session\\Session', $this->app->getSession());
     $this->assertInstanceOf('\\Starlit\\App\\Router', $this->app->getRouter());
     $this->assertInstanceOf('\\Starlit\\App\\View', $this->app->getView());
     $this->assertEquals($this->fakeConfig['testkey'], $this->app->getConfig()->get('testkey'));
     $this->assertEquals($this->fakeConfig['phpSettings']['max_execution_time'], ini_get('max_execution_time'));
     $this->assertEquals($this->fakeConfig['phpSettings']['date']['timezone'], ini_get('date.timezone'));
     // test setup default routes
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $this->app->getRouter()->getRoutes()->get('/'));
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $this->app->getRouter()->getRoutes()->get('/{action}'));
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $this->app->getRouter()->getRoutes()->get('/{controller}/{action}'));
 }
Пример #2
0
 /**
  * Forwards request to another action and/or controller
  *
  * @param string $action     Action name as lowercase separated string
  * @param string $controller Controller name as lowercase separated string
  * @param string $module     Module name as lowercase separated string
  * @param array  $actionArgs
  * @return Response
  */
 protected function forward($action, $controller = '', $module = '', array $actionArgs = [])
 {
     // Forward inside same controller (easy)
     if (!$controller) {
         return $this->dispatch($action, $actionArgs);
         // Forward to another controller
     } else {
         $module = $module ?: $this->module;
         $controller = $controller ?: $this->controller;
         $controllerClass = $this->app->getRouter()->getControllerClass($module, $controller);
         $actualController = new $controllerClass($this->app, $this->request);
         return $actualController->dispatch($action, $actionArgs);
     }
 }