示例#1
0
 /**
  * @test
  */
 public function playPublishesEachEvent()
 {
     $eventBus = $this->getMockBuilder(EventBus::class)->getMockForAbstractClass();
     $events = new Events([new EventPlayerTest_Event(), new EventPlayerTest_Event()]);
     $eventBus->expects(self::exactly($events->size()))->method('publish');
     $eventPlayer = new EventPlayer($eventBus);
     $eventPlayer->play($events);
 }
示例#2
0
 /**
  * @param Identity $aggregateId
  * @param int $version
  */
 public function playToVersion(Identity $aggregateId, int $version)
 {
     $events = $this->eventStore->getEventsForAggregate($aggregateId);
     $partialHistory = [];
     /* @var $event \Apha\Message\Event */
     foreach ($events->getIterator() as $event) {
         if ($event->getVersion() > $version) {
             break;
         }
         $partialHistory[] = $event;
     }
     $this->eventPlayer->play(new Events($partialHistory));
 }