function it_emits_money_transfer_requested(EventDispatcherInterface $dispatcher)
 {
     $dispatcher->dispatch(MoneyTransferRequestedEnvelope::getEventName(), Argument::type(MoneyTransferRequestedEnvelope::class))->shouldBeCalled();
     $events = new EventCollection([new MoneyTransferRequestedEvent(AccountNumber::fromString('123ABC'), new Transfer(Transaction::fromString('000'), AccountNumber::fromString('456DEF'), 100))]);
     $this->beConstructedWith($dispatcher);
     $this->emit($events);
 }
Exemple #2
0
 public function onTransferRequested(MoneyTransferRequestedEnvelope $event)
 {
     $this->assertProcessWasNotStarted($event->getTransaction());
     $process = new TransferProcess(Transaction::fromString($event->getTransaction()), AccountNumber::fromString($event->getSourceAccountNumber()), AccountNumber::fromString($event->getTargetAccountNumber()), $event->getAmount());
     $process->withdrawFromSource();
     $this->bus->handle(new TransferWithdrawCommand((string) $process->getSourceAccountNumber(), (int) $process->getAmount(), (string) $process->getTransaction()));
     $this->process[$event->getTransaction()] = $process;
 }
 function create_money_transfer_requested_envelope()
 {
     return MoneyTransferRequestedEnvelope::wrap(new MoneyTransferRequestedEvent(AccountNumber::fromString('123ABC'), new Transfer(Transaction::fromString('000'), AccountNumber::fromString('456DEF'), 100)));
 }