Example #1
0
 /**
  * Test AggregateId method.
  */
 public function testAggregateId()
 {
     $this->given($post = PostEventSourcedFactory::create($this->faker->sentence, $this->faker->paragraph))->and($snapshot = new Snapshot('posts', $post, new \DateTime()))->then()->object($snapshot->aggregateId())->isEqualTo($post->id());
 }
 /**
  * @param Snapshot $snapshot
  *
  * @return EventSourcedAggregateRootInterface
  */
 protected function snapshotToAggregateRoot(Snapshot $snapshot)
 {
     $applicationVersion = VersionManager::currentApplicationVersion();
     $history = $this->eventStore->load($this->streamName(), $snapshot->aggregateId(), $snapshot->version(), $applicationVersion);
     $aggregateRoot = $snapshot->aggregate();
     $aggregateRoot->setVersion($snapshot->version());
     $aggregateRoot->replay($history);
     return $aggregateRoot;
 }