/** * @param AggregateRoot $aggregate * @param integer $expectedPlayHead * @throws ConcurrencyException */ public function store(AggregateRoot $aggregate, $expectedPlayHead = -1) { $this->storage->save($aggregate->getId(), $aggregate->getUncommittedChanges(), $expectedPlayHead); }
public function testAppendEventForExistingAggregateWithWrongPlayheadThrowsException() { self::setExpectedException(ConcurrencyException::class); $aggregateId = Uuid::createNew(); $events = new Events([new FirstEvent()]); $eventBus = $this->getEventBus(); $storage = new MemoryEventStorage(); $serializer = $this->getSerializer(); $map = $this->getEventClassMap(); $store = new EventStore($eventBus, $storage, $serializer, $map); $store->save($aggregateId, $events, -1); $store->save($aggregateId, new Events([new SecondEvent()]), 1); }