/** * @param Request $request * * @return JsonResponse * @throws Exception */ public function handleSubmitTalk(Request $request) { try { $submission = TalkSubmission::fromNative($request->request->all()); $talk = $this->speakers->submitTalk($submission); return $this->setStatusCode(Response::HTTP_CREATED)->respond($talk->toArrayForApi()); } catch (InvalidTalkSubmissionException $e) { return $this->setStatusCode(Response::HTTP_BAD_REQUEST)->respondWithError($e->getMessage()); } catch (NotAuthenticatedException $e) { return $this->respondUnauthorized(); } catch (Exception $e) { return $this->respondInternalError($e->getMessage()); } }
/** @test */ public function it_doesnt_allow_talk_submissions_after_cfp_has_ended() { $this->callForProposal->shouldReceive('isOpen')->once()->andReturn(false); $this->setExpectedException('Exception', 'has ended'); $submission = TalkSubmission::fromNative(['title' => 'Sample Talk', 'description' => 'Some example talk for our submission', 'type' => 'regular', 'category' => 'api', 'level' => 'mid']); $this->sut->submitTalk($submission); }