/** * Bootstraps the application * * @param Application $app * * @return Application */ public function load(Application $app) { $app->get('/', 'Indigo\\Service\\Controller\\MainController::index'); $app->get('/services', 'Indigo\\Service\\Controller\\ServiceController::listAction'); $app->get('/services/create', 'Indigo\\Service\\Controller\\ServiceController::createAction'); $app->post('/services', 'Indigo\\Service\\Controller\\ServiceController::create'); $app->get('/services/{id}', 'Indigo\\Service\\Controller\\ServiceController::read'); $app->post('/services/{id}/comment', 'Indigo\\Service\\Controller\\ServiceController::createComment'); $app->get('/services/{id}/edit', 'Indigo\\Service\\Controller\\ServiceController::updateAction'); $app->post('/services/{id}', 'Indigo\\Service\\Controller\\ServiceController::update'); $app->delete('/services/{id}', 'Indigo\\Service\\Controller\\ServiceController::delete'); $app->get('/services/print/{id}', 'Indigo\\Service\\Controller\\ServiceController::pdf'); $app->get('/login', 'Indigo\\Service\\Controller\\AuthController::login'); $app->post('/login', 'Indigo\\Service\\Controller\\AuthController::processLogin'); $baseUriListener = new BaseUri(); $baseUriListener->setApplication($app); $app->subscribe('request.received', $baseUriListener); return $app; }
public function testRun() { $app = new Application(); $app->get('/', function ($request, $response) { $response->setContent('<h1>It works!</h1>'); return $response; }); $app->subscribe('request.received', function ($event, $request) { $this->assertInstanceOf('League\\Event\\Event', $event); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Request', $request); }); $app->subscribe('response.sent', function ($event, $request, $response) { $this->assertInstanceOf('League\\Event\\Event', $event); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Request', $request); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response); }); ob_start(); $app->run(); ob_get_clean(); }