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(); }
/** * Open stream * * @param Contract $streamContract * @param EventStreamIdentifier $streamIdentifier * * @return EventStream */ public function openStream(Contract $streamContract, EventStreamIdentifier $streamIdentifier) { return EventStream::open($this->persistence, $streamContract, $streamIdentifier); }
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())); }