public function testCommitDispatchesMessageProperly()
 {
     $stream = new MessageStream();
     $stream->push(new Message());
     $handler = new MessageHandler();
     $bus = new SymfonyEventDispatcherBus(new EventDispatcher());
     $bus->subscribe($handler);
     $bus->publish($stream);
     $bus->commit();
     $this->assertEquals('abc', $handler->getName());
 }
Пример #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());
 }
Пример #3
0
 public function testPushPreservesInsertionOrder()
 {
     $stream = new MessageStream();
     $stream->push(new Message(1));
     $stream->push(new Message(2));
     $this->assertEquals(1, $stream->current()->getId());
     $stream->next();
     $this->assertEquals(2, $stream->current()->getId());
 }