/**
  * @test
  * @covers ::findById
  */
 public function it_should_return_null_if_there_are_no_events_for_the_given_entity()
 {
     $streamUri = 'stream.id';
     $this->streamNameGenerator->shouldReceive('generate')->andReturn($streamUri);
     $this->eventStore->shouldReceive('forwardStreamFeedIterator')->once()->with($streamUri)->andReturn([]);
     $this->assertNull($this->repository->findById('1'));
 }
 public function commit()
 {
     if (count($this->events)) {
         $this->eventstore->writeToStream($this->streamUri, new WritableEventCollection($this->events));
     }
     $this->resetTransaction();
 }
 /**
  * @param $streamUri
  *
  * @return array
  */
 private function getDomainEventsFromStream($streamUri)
 {
     $events = [];
     $iterator = $this->eventstore->forwardStreamFeedIterator($streamUri);
     /** @var EntryWithEvent $entry */
     foreach ($iterator as $entry) {
         $event = $entry->getEvent();
         $events[] = $this->eventSerializer->unserialize($event->getType(), $event->getData());
     }
     return $events;
 }
 /**
  * @test
  * @covers ::commit
  */
 public function it_should_do_nothing_on_commit()
 {
     $this->eventstore->shouldReceive('writeToStream')->never();
     $this->transaction->commit();
 }
 public function push($streamUri, array $writeableEvents)
 {
     $collection = new WritableEventCollection($writeableEvents);
     $this->eventstore->writeToStream($streamUri, $collection);
 }
 /**
  * @test
  * @covers ::commit
  * @covers ::push
  */
 public function it_should_not_commit_if_there_are_no_events()
 {
     $this->eventstore->shouldReceive('writeToStream')->never();
     $this->transaction->push('streamUri', []);
     $this->transaction->commit();
 }