public function setUp()
 {
     parent::setUp();
     $bankAccount = new BankAccount();
     $bankAccount->setType(BankAccount::TYPE_NORMAL);
     $bankAccount->setBankName('ミツイスミトモ');
     $bankAccount->setBankCode('0009');
     $bankAccount->setBranchName('アカサカ');
     $bankAccount->setBranchCode('825');
     $bankAccount->setHolderName('スラビ');
     $bankAccount->setNumber('9876543');
     $bankAccount->setCompanyCode('1234560789');
     $this->transaction = new MoneyTransferTransaction();
     $this->transaction->setDestinationBankAccount($bankAccount);
     $this->transaction->setAmount(15234);
 }
 public function setUp()
 {
     parent::setUp();
     $senderBankAccount = new BankAccount();
     $senderBankAccount->setType(BankAccount::TYPE_NORMAL);
     $senderBankAccount->setBankName('ミツイスミトモ');
     $senderBankAccount->setBankCode('0009');
     $senderBankAccount->setBranchName('アカサカ');
     $senderBankAccount->setBranchCode('825');
     $senderBankAccount->setHolderName('スラビ');
     $senderBankAccount->setNumber('9876543');
     $senderBankAccount->setCompanyCode('1234560789');
     $this->transferRequest = new TransferRequest();
     $this->transferRequest->setType(TransferRequest::TYPE_GENERAL);
     $this->transferRequest->setSourceBankAccount($senderBankAccount);
     $this->transferRequest->setDate(\DateTime::createFromFormat('Y-m-d', '2016-02-25'));
     $receiverBankAccount = new BankAccount();
     $receiverBankAccount->setType(BankAccount::TYPE_NORMAL);
     $receiverBankAccount->setBankName('トウキョウトミン');
     $receiverBankAccount->setHolderName('テストー.カブシキガイシャ');
     //Note: using a normal dot/dash in this example
     $receiverBankAccount->setBankCode('0137');
     $receiverBankAccount->setBranchName('シブヤ');
     $receiverBankAccount->setBranchCode('031');
     $receiverBankAccount->setNumber('1231990');
     $receiverTransaction = new MoneyTransferTransaction();
     $receiverTransaction->setDestinationBankAccount($receiverBankAccount);
     $receiverTransaction->setAmount(1103661);
     $this->transferRequest->addTransaction($receiverTransaction);
     $receiverBankAccount = new BankAccount();
     $receiverBankAccount->setType(BankAccount::TYPE_NORMAL);
     $receiverBankAccount->setBankName('ベツバンク');
     $receiverBankAccount->setHolderName('ヒトノナマエ');
     //Note: using a normal dot/dash in this example
     $receiverBankAccount->setBankCode('0132');
     $receiverBankAccount->setBranchName('イケブクロ');
     $receiverBankAccount->setBranchCode('021');
     $receiverBankAccount->setNumber('1331990');
     $receiverTransaction = new MoneyTransferTransaction();
     $receiverTransaction->setDestinationBankAccount($receiverBankAccount);
     $receiverTransaction->setAmount(657856);
     $this->transferRequest->addTransaction($receiverTransaction);
 }
 public function testValidationFailsOnNon3DigitBranchCodes()
 {
     $this->account->setBranchCode('1234');
     $this->assertSame('1234', $this->account->getBranchCode());
     $violations = Validator::validateBankAccount($this->account, null);
     $this->assertTrue(count($violations) === 1);
     $this->assertTrue(count($violations->get('branchCode')) === 1);
     $this->account->setBranchCode('123 ');
     $this->assertSame('123 ', $this->account->getBranchCode());
     $violations = Validator::validateBankAccount($this->account, null);
     $this->assertTrue(count($violations) === 1);
     $this->assertTrue(count($violations->get('branchCode')) === 1);
     $this->account->setBranchCode('12');
     $this->assertSame('12', $this->account->getBranchCode());
     $violations = Validator::validateBankAccount($this->account, null);
     $this->assertTrue(count($violations) === 1);
     $this->assertTrue(count($violations->get('branchCode')) === 1);
     $this->account->setBranchCode('123');
     $this->assertSame('123', $this->account->getBranchCode());
     $violations = Validator::validateBankAccount($this->account, null);
     $this->assertTrue(count($violations) === 1);
     $this->assertTrue(count($violations->get('branchCode')) === 1);
     $this->account->setBranchCode('123');
     $this->assertSame('123', $this->account->getBranchCode());
     $violations = Validator::validateBankAccount($this->account, null);
     $this->assertTrue(count($violations) === 0);
     $this->account->setBranchCode('');
     $this->assertSame('', $this->account->getBranchCode());
     $violations = Validator::validateBankAccount($this->account, null);
     $this->assertTrue(count($violations) === 1);
     $this->assertTrue(count($violations->get('branchCode')) === 1);
     $this->account->setBranchCode(null);
     $this->assertSame(null, $this->account->getBranchCode());
     $violations = Validator::validateBankAccount($this->account, null);
     $this->assertTrue(count($violations) === 1);
     $this->assertTrue(count($violations->get('branchCode')) === 1);
 }
 public function testMultiTransaction()
 {
     $transferRequest = new TransferRequest();
     $transferRequest->setType(TransferRequest::TYPE_GENERAL);
     $transferRequest->setSourceBankAccount($this->account);
     $transferRequest->setDate(\DateTime::createFromFormat('Y-m-d', '2016-03-12'));
     $receiverBankAccount = new BankAccount();
     $receiverBankAccount->setType(BankAccount::TYPE_CURRENT);
     $receiverBankAccount->setBankName('トウキョウトミン');
     $receiverBankAccount->setHolderName('テストー.カブシキガイシャ');
     //Note: using a normal dot/dash in this example
     $receiverBankAccount->setBankCode('0137');
     $receiverBankAccount->setBranchName('シブヤ');
     $receiverBankAccount->setBranchCode('031');
     $receiverBankAccount->setNumber('1231990');
     $violations = Validator::validateBankAccount($receiverBankAccount, Validator::BANK_ACCOUNT_ROLE_RECEIVER);
     $this->assertTrue(count($violations) === 0);
     $receiverTransaction = new MoneyTransferTransaction();
     $receiverTransaction->setDestinationBankAccount($receiverBankAccount);
     $receiverTransaction->setAmount(1103661);
     $violations = Validator::validateMoneyTransferTransaction($receiverTransaction);
     $this->assertTrue(count($violations) === 0);
     $transferRequest->addTransaction($receiverTransaction);
     $receiverBankAccount = new BankAccount();
     $receiverBankAccount->setType(BankAccount::TYPE_NORMAL);
     $receiverBankAccount->setBankName('ミツビシトウキョウUFJ');
     $receiverBankAccount->setHolderName('カ)ゼンギン');
     //Note: using a normal dot in this example
     $receiverBankAccount->setBankCode('0005');
     $receiverBankAccount->setBranchName('ギンザドオリ');
     $receiverBankAccount->setBranchCode('024');
     $receiverBankAccount->setNumber('2275535');
     $violations = Validator::validateBankAccount($receiverBankAccount, Validator::BANK_ACCOUNT_ROLE_RECEIVER);
     $this->assertTrue(count($violations) === 0);
     $receiverTransaction = new MoneyTransferTransaction();
     $receiverTransaction->setDestinationBankAccount($receiverBankAccount);
     $receiverTransaction->setAmount(599300);
     $violations = Validator::validateMoneyTransferTransaction($receiverTransaction);
     $this->assertTrue(count($violations) === 0);
     $transferRequest->addTransaction($receiverTransaction);
     $zenginContentShiftJis = $this->generator->generate($transferRequest);
     //Let's verify that ミツビシトウキョウUFJ "small" (full-width + latin + small voiced) is converted correctly.
     //We do compare to the result file below, but we'd like to explicitly check for this beforehand anyway.
     $zenginContentUtf = \mb_convert_encoding($zenginContentShiftJis, 'utf-8', 'cp932');
     $this->assertTrue(str_replace('ミツビシトウキヨウUFJ', '', $zenginContentUtf) !== $zenginContentUtf);
     $this->assertTrue(str_replace(1103661 + 599300, '', $zenginContentUtf) !== $zenginContentUtf, "Cannot find total amount.");
     $this->validateZenginContent($zenginContentShiftJis, 'results/multi-transaction.txt');
 }