function testAcceptEmptyReturnsFirstFormat() { $app = new Bullet\App(); // Accept only JSON and request URL with no extension $req = new Bullet\Request('GET', '/foo', array()); $app->path('foo', function ($request) use($app) { $app->format('json', function ($request) { return array('foo' => 'bar'); }); }); $res = $app->run($req); $this->assertEquals('{"foo":"bar"}', $res->content()); $this->assertEquals('application/json', $res->contentType()); }
public function testStatusOnResponseObjectReturnsCorrectStatusAsJSON() { $app = new Bullet\App(); $app->path('posts', function ($request) use($app) { $app->post(function () use($app) { $app->format('json', function () use($app) { return $app->response(201, array('created' => 'something')); }); }); }); $actual = $app->run(new Bullet\Request('POST', 'posts.json')); $this->assertEquals(201, $actual->status()); }