private function createFixtures($entity, $id)
 {
     $stream = new EventStream();
     $stream->recordThat(EventMessage::record(new CreationEvent($id), new EntityDTO($entity, $id, 1)));
     $stream->recordThat(EventMessage::record(new ModificationEvent('new value'), new EntityDTO($entity, $id, 2)));
     $stream->recordThat(EventMessage::record(new ModificationEvent('last value'), new EntityDTO($entity, $id, 3)));
     $this->storage->saveStream($stream);
 }
 public function test_it_can_record_events()
 {
     $Stream = new EventStream();
     $Stream->recordThat(EventMessage::record(new EventDouble('event 1'), new EntityDTO('Entity', new Id(1))));
     $this->assertEquals(1, $Stream->count());
     $Stream->recordThat(EventMessage::record(new EventDouble('event 2'), new EntityDTO('Entity', new Id(1))));
     $this->assertEquals(2, $Stream->count());
     $Stream->recordThat(EventMessage::record(new EventDouble('event 3'), new EntityDTO('Entity', new Id(1))));
     $this->assertEquals(3, $Stream->count());
 }
 public function loadStream(EntityDTO $entity)
 {
     $stream = new EventStream();
     foreach ($this->getStoredData($entity) as $dto) {
         $stream->recordThat(EventMessage::fromEventDTO($dto));
     }
     return $stream;
 }
 private function prepare_stream_for_entity($entity, $eventCount)
 {
     $stream = new EventStream();
     for ($i = 0; $i < $eventCount; $i++) {
         $event = $this->getEvent('Event_' . $i);
         $stream->recordThat(EventMessage::record($event, $entity));
     }
     return $stream;
 }
 private function prepareEventStream($entity, $id, $maxVersion)
 {
     $stream = new EventStream();
     for ($version = 1; $version <= $maxVersion; $version++) {
         $message = new EventMessage(new EventDouble($id), new EntityDTO($entity, $id, $version), EventEnvelope::now());
         $stream->recordThat($message);
     }
     return $stream;
 }