function let() { $this->postId = PostId::generate(); $this->author = 'Ellis'; $this->content = 'Bob has written this'; $this->beConstructedThrough('create', [$this->postId, $this->author, $this->content]); }
function let() { $this->postId = PostId::generate(); $this->title = 'Post title'; $this->publishingDate = new \DateTime(); $this->beConstructedWith($this->postId, $this->title, $this->publishingDate); }
function let() { $this->postId = PostId::generate(); $this->title = 'title'; $this->content = 'content'; $this->beConstructedWith($this->postId, $this->title, $this->content); }
function let() { $this->commentId = CommentId::generate(); $this->postId = PostId::generate(); $this->author = 'Rochelle'; $this->content = 'Comment'; $this->creatingDate = new \DateTime(); $this->beConstructedWith($this->commentId, $this->postId, $this->author, $this->content, $this->creatingDate); }
function it_should_run_populator(BulkProjectionStorage $projectionStorage, EventStorage $eventStorage, DomainEventListener $listener) { $projectionStorage->find('post-list')->willReturn($projections = [new PostListProjection(PostId::generate(), 'Post title', new \DateTime())]); foreach ($projections as $projection) { $projectionStorage->remove($projection)->shouldBeCalled(); } $projectionStorage->flush()->shouldBeCalled(); $eventStorage->getAll()->willReturn($events = [new PostWasPublished(PostId::generate(), 'title', 'content', new \DateTime())]); foreach ($events as $event) { $eventClass = explode('\\', get_class($event)); $method = 'on' . end($eventClass); if (method_exists($listener, $method)) { $listener->when($event)->shouldBeCalled(); } } $projectionStorage->flush()->shouldBeCalled(); $this->run(); }
/** * @param string $title * @param string $content * @return Post */ public static function create($title, $content) { $post = new self($postId = PostId::generate()); $post->setTitle($title); $post->setContent($content); $post->setPublishingDate($publishingDate = new \DateTime()); $post->recordThat(new PostWasPublished($postId, $title, $content, $publishingDate)); return $post; }
function it_should_trigger_post_list_projection_update(PostListListener $postListListener) { $postListListener->when(Argument::type(PostWasPublished::class))->shouldBeCalled(); $this->registerListener($postListListener); $this->dispatch([new PostWasPublished(PostId::generate(), 'title', 'content', new \DateTime())]); }
function it_should_update_post_list_projection(ProjectionStorage $projectionStorage) { $event = new PostWasPublished(PostId::generate(), 'title', 'content', new \DateTime()); $projectionStorage->save(Argument::type(PostListProjection::class))->shouldBeCalled(); $this->when($event); }