public function testValidationFailsWithCorruptedBankAccount()
 {
     //Ensuring that validation cascades and checks the bank account.
     $bankAccount = $this->transaction->getDestinationBankAccount();
     $bankAccount->setNumber(null);
     $violations = Validator::validateMoneyTransferTransaction($this->transaction);
     $this->assertTrue(count($violations) === 1);
     $this->assertTrue(count($violations->get('destinationBankAccount')) === 1);
 }
Пример #2
0
 private function generateTransactionLine(MoneyTransferTransaction $transaction)
 {
     $items = array();
     $items[] = array('%1d', self::RECORD_DATA);
     $items[] = array('%04d', $transaction->getDestinationBankAccount()->getBankCode());
     $bankName = $transaction->getDestinationBankAccount()->getBankName();
     $bankNameHalfWidth = StringUtil::convertFullWidthToHalfWidthKana($bankName);
     $items[] = array('%s', StringUtil::stringPadRight($bankNameHalfWidth, 15, ' '));
     $items[] = array('%03d', $transaction->getDestinationBankAccount()->getBranchCode());
     $branchName = $transaction->getDestinationBankAccount()->getBranchName();
     $branchNameHalfWidth = StringUtil::convertFullWidthToHalfWidthKana($branchName);
     $items[] = array('%s', StringUtil::stringPadRight($branchNameHalfWidth, 15, ' '));
     //Clearing-house number
     $items[] = array('%04d', 0);
     $items[] = array('%1d', self::resolveBankAccountType($transaction->getDestinationBankAccount()->getType()));
     $items[] = array('%07d', $transaction->getDestinationBankAccount()->getNumber());
     $holderName = $transaction->getDestinationBankAccount()->getHolderName();
     $holderNameHalfWidth = StringUtil::convertFullWidthToHalfWidthKana($holderName);
     $items[] = array('%s', StringUtil::stringPadRight($holderNameHalfWidth, 30, ' '));
     $items[] = array('%010d', $transaction->getAmount());
     //New Code: 1 (new), 2 (change), 0 (other)
     $items[] = array('%d', 0);
     if ($transaction->getMemberCode()) {
         $items[] = array('%010d', $transaction->getMemberCode());
     } else {
         $items[] = array('%s', str_repeat(' ', 10));
     }
     if ($transaction->getAffiliationCode()) {
         $items[] = array('%010d', $transaction->getAffiliationCode());
     } else {
         $items[] = array('%s', str_repeat(' ', 10));
     }
     //Transfer designation classification: 7 (Tele-Exchange)
     $items[] = array('%d', 7);
     //Identification
     $items[] = array('%s', ' ');
     $items[] = array('%s', str_repeat(' ', 7));
     return StringUtil::sprintfItemGroupsToString($items);
 }