function it_is_add_account_correct(AccountRepository $accountRepository, BankAccount $oBankAccount, Client $oClient) { $oBankAccountWrapped = $oBankAccount->getWrappedObject(); $accountRepository->add($oBankAccountWrapped)->shouldBeCalled(); $oBankAccount->setIdClient($oClient->getId()); $this->beConstructedWith($accountRepository->getWrappedObject()); $this->add($oClient->getWrappedObject(), $oBankAccountWrapped); }
/** * @param ExchangeCurrencyCommand $command * @throws BankAccountNotFoundException */ public function exchange(ExchangeCurrencyCommand $command) { $data = $command->getPayload(); //ToDo 3.50 zamienic na mechaznim ktory wyciaga wartosc waluty $exchangeRate = new ExchangeRate(new Currency($data['currency_code']), new Amount(3.5)); $bankAccountTransactionSource = $this->_accountRepo->byId($data['id_account_in']); if (is_null($bankAccountTransactionSource)) { throw new BankAccountNotFoundException('Nie znaleziono numeru konto o id ' . $data['id_account_in']); } $bankAccountTransactionTarget = $this->_accountRepo->byId($data['id_account_return']); if (is_null($bankAccountTransactionTarget)) { throw new BankAccountNotFoundException('Nie znaleziono numeru konto o id ' . $data['id_account_return']); } $exchangeRateSummary = new ExchangeSummary($exchangeRate, $data['quantity']); $exchangeRateSummary->confirm($bankAccountTransactionSource, $bankAccountTransactionTarget); $this->_exchangeSummaryRepo->confirm($exchangeRateSummary); }