예제 #1
0
 /**
  * @test
  */
 public function it_starts_a_new_chapter_by_providing_the_chapter_command()
 {
     $fileWasUploaded = new FileWasUploaded();
     $startCondition = $this->prophesize(MessageCondition::class);
     $startCondition->isTrueFor($fileWasUploaded)->willReturn(true);
     $isDoneCondition = $this->prophesize(MessageCondition::class);
     $payloadGenerator = $this->prophesize(PayloadGenerator::class);
     $payloadGenerator->__invoke(Argument::any(), Argument::any(), Argument::any())->will(function ($args) {
         list($previousMessage, $payload, $metadata) = $args;
         $payload['filename'] = $previousMessage->payload()['filename'];
     });
     $commandTemplate = new MessageTemplate(ProcessFile::class, new FQCNMessageFactory(), [], [], $payloadGenerator->reveal());
     $chapterTemplate = new ChapterTemplate(ChapterName::fromString('File Processor'), $commandTemplate, $startCondition->reveal(), $isDoneCondition->reveal());
     $storyId = StoryId::generateNew();
     $chapterNumber = ChapterNumber::withNumber($storyId, 2);
     $chapterCommand = $chapterTemplate->startChapter(StoryName::fromString('Test Story'), $chapterNumber, $fileWasUploaded);
     $this->assertInstanceOf(ProcessFile::class, $chapterCommand);
     $this->assertEquals('some-file.csv', $chapterCommand->payload()['filename']);
     $this->assertEquals($chapterNumber->toString(), $chapterCommand->metadata()[Metadata::STORY_CHAPTER]);
     $this->assertEquals('Test Story', $chapterCommand->metadata()[Metadata::STORY_NAME]);
 }
예제 #2
0
 /**
  * @return \Prooph\Done\Shared\ChapterNumber
  */
 private function getChapterNumber()
 {
     return ChapterNumber::first(StoryId::generateNew());
 }