/** * @test * @expectedException \Prooph\Done\Shared\Exception\ChapterStatus */ public function it_does_not_allow_to_mark_a_done_chapter_as_failed() { $chapterStatus = ChapterStatus::chapterWasStarted($this->getChapterName(), $this->getChapterNumber()); $chapterStatus = $chapterStatus->markChapterAsDone(); $chapterStatus->markChapterAsFailed(); }
/** * @param Shared\StoryName $storyName * @param Message $message * @param ChapterTemplate[] $chapterTemplates * @param Shared\StoryId $storyId * @param MessageConverter $messageConverter * @return Message[] */ private function startNextChapters(StoryName $storyName, Message $message, array &$chapterTemplates, StoryId $storyId, MessageConverter $messageConverter) { $chapterCommands = []; $chapterStates = $this->chapterStates ?: []; foreach ($chapterTemplates as $chapterTemplate) { if ($chapterTemplate->isStartedBy($message)) { $chapterNumber = $this->getNextChapterNumber($storyId, $chapterStates); $chapterCommand = $chapterTemplate->startChapter($storyName, $chapterNumber, $message); $newChapterStatus = ChapterStatus::chapterWasStarted($chapterTemplate->desiredChapterName(), $chapterNumber, $chapterTemplate->retryLimit()); $this->recordThat(ChapterWasStarted::withStatusByMessage($newChapterStatus, $messageConverter->convertToArray($message))); $chapterCommands[] = $chapterCommand; $chapterStates[$newChapterStatus->chapterNumber()->index()] = $newChapterStatus; } } return $chapterCommands; }