Esempio n. 1
0
 public function testCommitEmpty()
 {
     $identifier = EventStreamIdentifier::fromString('Foo');
     $contract = Contract::fromClass(\stdClass::class);
     $this->persistence->expects($this->never())->method('commit');
     $stream = EventStream::create($this->persistence, $contract, $identifier);
     $stream->commit();
 }
Esempio n. 2
0
 /**
  * Open stream
  *
  * @param Contract              $streamContract
  * @param EventStreamIdentifier $streamIdentifier
  *
  * @return EventStream
  */
 public function openStream(Contract $streamContract, EventStreamIdentifier $streamIdentifier)
 {
     return EventStream::open($this->persistence, $streamContract, $streamIdentifier);
 }
Esempio n. 3
0
 private function reconstitute($aggregateClassName, EventStream $stream)
 {
     if (!is_a($aggregateClassName, AggregateRoot::class, true)) {
         throw AggregateIsInvalidInstanceException::forClass($aggregateClassName);
     }
     /** @var $aggregateClassName AggregateRoot */
     return $aggregateClassName::reconstituteFrom(new EventCollection($stream->all()));
 }