/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $text = array(); $accountType = $input->getArgument(self::ARGUMENT_ACCOUNT_TYPE); $accountNumber = $input->getArgument(self::ARGUMENT_ACCOUNT_NUMBER); $depositAmount = round($input->getArgument(self::ARGUMENT_DEPOSIT_AMOUNT), 2); $overdraftAmount = round($input->getArgument(self::ARGUMENT_OVERDRAFT_AMOUNT), 2); $withdrawAmount = round($input->getArgument(self::ARGUMENT_WITHDRAW_AMOUNT), 2); //create a new account switch ($accountType) { case Account::TYPE_CURRENT: $account = new CurrentAccount($accountNumber); break; } //TODO check if account exists and handle accordingly $account->open(); //output text $text[] = 'A new ' . $accountType . ' account has been created with the account number [' . $accountNumber . '].'; //if a deposit has been made if ($depositAmount && $depositAmount > 0) { $account->deposit((double) $depositAmount); $text[] = 'A deposit of ' . $depositAmount . ' was made.'; } //if overdraft is required if ($overdraftAmount && $overdraftAmount > 0) { $account->setOverdraft(new \Cilex\Bank\OverdraftService($account), (double) $overdraftAmount); $text[] = 'An overdraft of ' . $overdraftAmount . ' was set.'; } //if a withdraw is made if ($withdrawAmount && $withdrawAmount > 0) { $account->withdraw((double) $withdrawAmount); $text[] = 'A withdraw of ' . $withdrawAmount . ' was made.'; } //if the option 'overdraft' is requested give the overdraft status. $input->getOption(self::OPTION_OVERDRAFT) ? $text[] = 'The account has an overdraft limit of ' . $account->getOverdraftLimit() . '.' : false; //if the option 'balance' is requested give the account balance. $input->getOption(self::OPTION_BALANCE) ? $text[] = 'The account has a balance of ' . $account->getBalance() . '.' . PHP_EOL : false; //output $output->writeln($text); }
/** * @covers Cilex\Bank\CurrentAccount::setOverdraft */ public function testSetBadOverdraftLimit() { $this->assertFalse($this->object->setOverdraft($this->mockOverdraftObject, '100')); }