/**
  * @param TransferFundsRequest $request
  */
 public function transfer(TransferFundsRequest $request)
 {
     $fromMember = $this->members->with($request->fromMemberId());
     $toMember = $this->members->with($request->toMemberId());
     $fromMember->transfer($request->amount(), $toMember);
     $this->members->update($fromMember);
     $this->members->update($toMember);
     $this->publisher()->publish($fromMember->events());
     $this->notifier()->transferCompleted(new TransferFundsResponse($fromMember, $toMember));
 }
 /**
  * @param FilteredRequest $request
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function transfer(FilteredRequest $request)
 {
     if (!$request->isValid()) {
         $this->validationFailedFor($request);
     } else {
         $this->useCase->transfer(TransferFundsRequest::from($request->values()));
     }
     return $this->responder->response();
 }
 function it_should_transfer_funds_between_accounts(Members $members, TransferFundsNotifier $notifier)
 {
     $fromMember = A::member()->withBalance(2000)->build();
     $toMember = A::member()->withBalance(1000)->build();
     $members->with($fromMember->information()->id())->willReturn($fromMember);
     $members->with($toMember->information()->id())->willReturn($toMember);
     $members->update($fromMember)->shouldBeCalled();
     $members->update($toMember)->shouldBeCalled();
     $this->beConstructedWith($members);
     $this->attach($notifier);
     $this->transfer(TransferFundsRequest::from(['fromMemberId' => (string) $fromMember->information()->id(), 'toMemberId' => (string) $toMember->information()->id(), 'amount' => 5]));
     $notifier->transferCompleted(Argument::type(TransferFundsResponse::class))->shouldHaveBeenCalled();
 }
 /** @test */
 function it_should_transfer_funds_between_members()
 {
     Fixtures::load(__DIR__ . '/../../../_data/fixtures/members.yml', $this->entityManager);
     /** @var Members $members */
     $members = $this->entityManager->getRepository(Member::class);
     $notifier = Mockery::mock(TransferFundsNotifier::class)->shouldIgnoreMissing();
     $transferBalance = new TransferFunds($members);
     $transferBalance->attach($notifier);
     $transferBalance->transfer($request = TransferFundsRequest::from(['fromMemberId' => 'XYZ', 'toMemberId' => 'ABC', 'amount' => 3]));
     $fromMember = $members->with($request->fromMemberId());
     $this->assertBalanceAmounts(700, $fromMember);
     $toMember = $members->with($request->toMemberId());
     $this->assertBalanceAmounts(1300, $toMember);
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->useCase->transfer(TransferFundsRequest::from($input->getArguments()));
 }
 /**
  * @When I transfer him :amount MXN
  */
 public function iTransferHimMxn($amount)
 {
     $this->useCase->transfer(TransferFundsRequest::from(['fromMemberId' => 'abc', 'toMemberId' => 'xyz', 'amount' => round($amount->getAmount() / 100)]));
 }