/** * @param Uuid $aggregateId * @param Events $events * @param integer $expectedPlayHead * @throws ConcurrencyException */ public function save(Uuid $aggregateId, Events $events, $expectedPlayHead) { $expectedPlayHead = (int) $expectedPlayHead; if (!$this->isValidPlayHead($aggregateId, $expectedPlayHead)) { throw new ConcurrencyException($expectedPlayHead, $this->current->get($aggregateId->getValue())); } $playHead = $expectedPlayHead; foreach ($events->getIterator() as $event) { /* @var $event Event */ $playHead++; $event->setVersion($playHead); $this->saveEvent($aggregateId, $event); $this->current->put($aggregateId->getValue(), $playHead); $this->eventBus->publish($event); } }
public function testPublishWithoutHandlerDoesNotDoAnything() { $event = $this->getMockBuilder(Event::class)->getMock(); $eventBus = new EventBus([]); $eventBus->publish($event); }