Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /** @test */
 public function it_should_allow_authenticated_speakers_to_submit_talks()
 {
     $this->callForProposal->shouldReceive('isOpen')->once()->andReturn(true);
     $this->identityProvider->shouldReceive('getCurrentUser')->once()->andReturn($this->getSpeaker());
     $this->talkRepository->shouldReceive('persist')->with(m::type('OpenCFP\\Domain\\Entity\\Talk'))->once();
     $this->dispatcher->shouldReceive('dispatch')->with('opencfp.talk.submit', m::type('OpenCFP\\Domain\\Talk\\TalkWasSubmitted'))->once();
     $submission = TalkSubmission::fromNative(['title' => 'Sample Talk', 'description' => 'Some example talk for our submission', 'type' => 'regular', 'category' => 'api', 'level' => 'mid']);
     /**
      * This should determine the current authenticated speaker, create a Talk from
      * the data in the TalkSubmission and then persist that Talk. It should dispatch
      * an event when a talk is submitted.
      */
     $this->sut->submitTalk($submission);
 }