function testCacheWithSeconds() { $app = new Bullet\App(); $req = new Bullet\Request('GET', '/cache'); $currentTime = time(); $cacheTime = 3600; $app->path('cache', function ($request) use($app, $cacheTime) { $app->get(function ($request) use($app, $cacheTime) { return $app->response(200, 'CONTENT')->cache($cacheTime); }); }); $res = $app->run($req); $this->assertEquals('CONTENT', $res->content()); $this->assertEquals('public, max-age=3600', $res->header('Cache-Control')); $this->assertEquals(gmdate("D, d M Y H:i:s", time() + $cacheTime), $res->header('Expires')); }
public function testSupportsHeadWithHandler() { $app = new Bullet\App(); $app->path('test', function ($request) use($app) { $app->head(function ($request) use($app) { return $app->response()->header('X-Special', 'Stuff'); }); $app->get(function ($request) { return 'I am hidden with a HEAD request!'; }); }); $request = new \Bullet\Request('HEAD', '/test'); $response = $app->run($request); $this->assertEquals('HEAD', $request->method()); $this->assertEquals('Stuff', $response->header('X-Special')); $this->assertEquals('', $response->content()); }