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); }
public function add(AddBankAccountCommand $accountCommand) { $aData = $accountCommand->getPayload(); $client = $this->_clientRepo->byId($aData['id_client']); if (is_null($client) || empty($client)) { throw new ClientNotFoundException(); } $bankAccount = new BankAccount(new NumberAccount($aData['number']), new Currency($aData['country_code'])); $bankAccount->setIdClient($client->getId()); $this->_accountRepo->add($bankAccount); }