function testOptionsHeaderWithCustomOptionsRoute() { $app = new Bullet\App(); $req = new Bullet\Request('OPTIONS', '/test'); $app->path('test', function ($request) use($app) { $app->get(function ($request) { return 'GET'; }); $app->post(function ($request) { return 'POST'; }); $app->options(function ($request) { return 'OPTIONS'; }); }); $res = $app->run($req); $this->assertEquals('OPTIONS', $res->content()); $this->assertEquals(false, $res->header('Allow')); }
public function testEventHandlerBefore() { $app = new Bullet\App(); $app->path('testhandler', function () use($app) { $app->post(function ($request) use($app) { return $request->foo; }); }); // Register custom handler $app->on('before', function ($request, $response) { $request->foo = 'bar'; }); $response = $app->run(new Bullet\Request('POST', 'testhandler')); $this->assertEquals('bar', $response->content()); }