/** * {@inheritDoc} */ private function loadFromSnapshotStore(AggregateIdInterface $aggregateId, StreamName $streamName = null) { $snapshot = $this->snapshotter->get($aggregateId); if (null === $snapshot) { return null; } $streamName = $this->determineStreamName($streamName); $aggregateRoot = $snapshot->getAggregate(); $stream = $this->eventStore->fromVersion($streamName, $aggregateId, $snapshot->getVersion() + 1); if (!$stream->getIterator()->valid()) { return $aggregateRoot; } $aggregateRoot->replay($stream); return $aggregateRoot; }
private function setUpForEventStream(EventStream $stream) { $this->eventStore = $this->prophesize(EventStoreInterface::class); $this->eventStore->append($stream)->shouldBeCalled(); $this->eventBus = $this->prophesize(EventBusInterface::class); $stream->each(function (DomainMessage $domainMessage) { $this->eventBus->publish($domainMessage->getPayload())->shouldBeCalled(); }); }
/** * @inheritdoc */ public function isFulfilled(StreamName $streamName, AggregateRootInterface $aggregate) { $countOfEvents = $this->eventStore->countEventsFor($streamName, $aggregate->getAggregateRootId()); return $countOfEvents && $countOfEvents % $this->count === 0; }
/** * @test * @dataProvider idDataProvider * @expectedException \HelloFresh\Engine\EventStore\Exception\EventStreamNotFoundException */ public function it_throws_an_exception_when_requesting_the_stream_of_a_non_existing_aggregate($id) { $this->eventStore->getEventsFor(new StreamName('event_stream'), $id); }