Exemple #1
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());
 }
 /**
  * @param Customer $customer
  * @return Customer
  */
 protected function saveCustomer(Customer $customer)
 {
     $this->customerRepository->save($customer);
     $this->eventStore->commit();
     return $this->customerRepository->findById($customer->getId());
 }
 /**
  * {@inheritdoc}
  */
 public function save(EventProviderInterface $eventProvider)
 {
     $this->eventStore->addEventStream($eventProvider->getUncommittedEventStream());
     $eventProvider->clear();
 }