public function testReturnStatusCodeGetterSetter() { $statusCode = Response::HTTP_NOT_MODIFIED; $responseContainer = new ResponseModel(); $responseContainer->setReturnStatusCode($statusCode); $this->assertEquals($statusCode, $responseContainer->getReturnStatusCode()); }
public function testToArrayStatusCode() { $responseContainer = new ResponseModel(); $responseContainer->setData('foo'); $responseContainer->setReturnStatusCode(true); $result = $responseContainer->toArray(); $this->assertEquals(Response::HTTP_OK, $result['statusCode']); }
/** * Check if we should put the status code in the output and force a 200 OK in the header * * @param Request $request * @param SymfonyResponse $response * @param ResponseModel $responseModel */ protected function forceStatusCodeHttpOK(Request $request, SymfonyResponse $response, ResponseModel $responseModel) { if ($request->headers->has('X-Force-Status-Code-200') || $request->getRequestFormat() == Format::FORMAT_JSON && $request->query->has(self::PARAMETER_CALLBACK)) { $responseModel->setReturnStatusCode(true); $response->setStatusCode(Response::HTTP_OK); $response->headers->set('X-Status-Code', Response::HTTP_OK); } }