public function testRootWillBeReconstitutedFromStream() { $contract = Contract::fromClass(AggregateRootDouble::class); $eventStreamId = EventStreamIdentifier::fromString('test'); $event = $this->getMock(DomainEvent::class); $this->persistence->expects($this->any())->method('fetch')->willReturn([$event]); $aggregate = $this->uow->get($contract, $eventStreamId); $this->assertEquals([$event], iterator_to_array($aggregate->events)); }
public function testCommitStreamWithoutChanges() { $contract = Contract::fromClass(static::class); $identifier = EventStreamIdentifier::fromString('foo'); $root = $this->getMock(AggregateRoot::class); $root->expects($this->any())->method('getRecordedEvents')->willReturn([]); $this->persistence->expects($this->any())->method('fetch')->willReturn([]); $this->persistence->expects($this->never())->method('commit'); $this->eventEmitter->expects($this->never())->method('emit'); $this->uow->track($contract, $identifier, $root); $this->uow->commit(); }