Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function commit()
 {
     if ($this->eventStorage instanceof TransactionalInterface) {
         $this->eventStorage->beginTransaction();
     }
     foreach ($this->identityMap as $eventStream) {
         $this->eventStorage->saveUncommittedEventStream($eventStream);
         $this->eventBus->publish(new MessageStream($eventStream));
     }
     if ($this->eventStorage instanceof TransactionalInterface) {
         $this->eventStorage->commit();
     }
     $this->eventBus->commit();
     $this->identityMap->clear();
 }
Exemplo n.º 2
0
 public function testChangeCustomerName()
 {
     $id = Uuid::uuid4();
     $stream = new MessageStream();
     $stream->push(new CreateCustomerCommand($id, CustomerName::GENDER_MALE, 'abc', 'def', '*****@*****.**'));
     $stream->push(new ChangeCustomerNameCommand($id, CustomerName::GENDER_MALE, 'mno', 'pqr', '*****@*****.**'));
     $this->commandBus->publish($stream);
     $this->commandBus->commit();
     $this->eventStore->commit();
     /** @var Customer $persisted */
     $persisted = $this->repository->findById($id);
     $name = $persisted->getName();
     $this->assertEquals(CustomerName::GENDER_MALE, $name->getGender());
     $this->assertEquals('mno', $name->getFirstName());
     $this->assertEquals('pqr', $name->getLastName());
     $this->assertEquals('*****@*****.**', $name->getEmail());
 }