/** * @internal * * @param AggregateRoot $aggregateRoot */ public function doSave(AggregateRoot $aggregateRoot) { $eventStream = $aggregateRoot->uncommittedChanges(); if (!$eventStream->isEmpty()) { $this->eventStore->append($this->aggregateRootType, $eventStream); } }
public function it_should_not_solicitate_the_event_store_if_there_are_not_uncommitted_changes(AggregateRoot $aggregateRoot, $eventStore, $aggregateRootType, EventStream $eventStream) { $aggregateRoot->uncommittedChanges()->willReturn($eventStream); $eventStream->isEmpty()->willReturn(true); $eventStore->append(Argument::cetera())->shouldNotBeCalled(); $this->doSave($aggregateRoot); }