public function createApplication() { $app = new Application(); $app->match('/hello', function () { return 'world'; }); $app->match('/html', function () { return '<h1>title</h1>'; }); $app->match('/server', function () use($app) { $user = $app->getRequest()->server->get('PHP_AUTH_USER'); $pass = $app->getRequest()->server->get('PHP_AUTH_PW'); return "<h1>{$user}:{$pass}</h1>"; }); return $app; }
public function testExceptionHandlerExceptionDebug() { $app = new Application(['debug' => true]); $app->match('foo', '/foo', function () { throw new \RuntimeException('foo exception'); }); $response = $app->handle(Request::create('/foo')); $this->assertContains('foo exception', $response->getContent()); $this->assertEquals(500, $response->getStatusCode()); }