/** * Orchestrates the use-case of a speaker submitting a talk. * * @param TalkSubmission $submission * * @return Talk * @throws \Exception */ public function submitTalk(TalkSubmission $submission) { if (!$this->callForProposal->isOpen()) { throw new \Exception('You cannot create talks once the call for papers has ended.'); } $user = $this->identityProvider->getCurrentUser(); // Create talk from submission. $talk = $submission->toTalk(); // Own the talk to the speaker. $talk->user_id = $user->id; $this->talks->persist($talk); $this->dispatcher->dispatch('opencfp.talk.submit', new TalkWasSubmitted($talk)); return $talk; }
/** @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); }
/** @test */ public function it_should_say_cfp_is_closed_after_end_date_has_passed() { $cfp = new CallForProposal(new DateTime('-1 day')); $this->assertFalse($cfp->isOpen()); }