/** * @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); }
public function it_can_register_an_aggregate_root_and_return_it(AggregateRoot $aggregateRoot, $eventRegistrationCallback, $eventBus, $saveAggregateCallback) { $aggregateRoot->addEventRegistrationCallback($eventRegistrationCallback)->shouldBeCalled(); $this->add($aggregateRoot, $eventBus, $saveAggregateCallback)->shouldReturn($aggregateRoot); }
/** * @param AggregateRoot $aggregateRoot * * @return mixed */ public final function sameIdentityAs(AggregateRoot $aggregateRoot) { if (!$aggregateRoot instanceof static) { return false; } return $this->identifier()->sameValueAs($aggregateRoot->identifier()); }