/** * Respond with a created response and associate a location if provided. * * @param null|string $location * * @return \Dingo\Api\Http\ResponseBuilder */ public function created($location = null) { $response = new ResponseBuilder(null); $response->setStatusCode(201); if (!is_null($location)) { $response->header('Location', $location); } return $response; }
public function testBuildingWithCustomStatusCodeAndHeaders() { $builder = new ResponseBuilder('test'); $builder->statusCode(302); $builder->header('Foo', 'Bar'); $response = $builder->build(); $this->assertEquals('Bar', $response->headers->get('Foo')); $this->assertEquals(302, $response->getStatusCode()); }