コード例 #1
0
 public function testStorage()
 {
     $id = TicketId::generate();
     $message = DomainMessage::create($id, 1, new TicketWasCreated($id, 'iqbal', 'Cannot save data.'));
     $this->storage->append('Ticket', $message, 'OK');
     $eventStream = $this->storage->findEventFromBeginning('Ticket', $id);
     $events = $eventStream->all();
     $this->assertCount(1, $eventStream);
     $this->assertInstanceOf('\\Borobudur\\EventSourcing\\Test\\Event\\TicketWasCreated', $events[0]->getPayload());
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function apply(DomainEventInterface $event)
 {
     if (true === $this->terminated) {
         throw new LogicException(sprintf('"%s" with id "%s" has been deleted.', get_called_class(), $this->getId()));
     }
     $this->handleRecursively($event);
     $this->uncommittedEvents[] = DomainMessage::create($this->getId(), ++$this->version, $event);
 }
コード例 #3
0
 private function append($id)
 {
     $message = DomainMessage::create($id, 1, new TicketWasCreated($id, 'iqbal', 'Testing data.'));
     $this->storage->append('Ticket', $message, 'OK');
 }