Ejemplo n.º 1
0
 /**
  * @depends testNewFrontController
  */
 public function testRunFrontControllerParam()
 {
     //start router
     $router = new Router($this->routes, array('basePath' => '/', 'badRoute' => 'E404', 'rewriteMode' => true));
     //evaluate request uri
     $router->validate('/Foo/data500/modifyDataFromParam', 'GET');
     $model = new FOOModel();
     //get view linked to route
     $view = new FOOView($model, new FOOTemplate());
     //get controller linked to route
     $controller = new FOOController($model);
     $FrontController = new FrontController($router->getRoute(), $model, $view, $controller);
     $FrontController->run();
     ob_start();
     $FrontController->response();
     $test = json_decode(ob_get_contents());
     ob_end_clean();
     $this->assertInstanceOf(stdClass::class, $test);
     $this->assertEquals('data500', $test->data);
 }
Ejemplo n.º 2
0
 * Router Section
 *
 */
//start router
$router = new Router($appRoutes, $options['router']);
//evaluate request uri and method
$router->validate($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
//get route
$route = $router->getRoute();
//get model linked to route
$routeModel = '\\App\\Models\\' . $route->getModel();
//get view linked to route
$routeView = '\\App\\Views\\' . $route->getView();
//get controller linked to route
$routeController = '\\App\\Controllers\\' . $route->getController();
//resolve model
$model = $DIResolver->resolve($routeModel);
//resolve view
$view = $DIResolver->resolve($routeView);
//resolve controller
$controller = $DIResolver->resolve($routeController);
/**
 * Front Controller section
 *
 */
//start front controller
$frontController = new FrontController($route, $model, $view, $controller);
//run
$frontController->run();
//get front controller response
$frontController->response();