public function testValidationFailsWithBadAmounts() { $this->transaction->setAmount(null); $this->assertSame(null, $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 1); $this->assertTrue(count($violations->get('amount')) === 1); $this->transaction->setAmount(''); $this->assertSame('', $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 1); $this->assertTrue(count($violations->get('amount')) === 1); $this->transaction->setAmount('500円'); $this->assertSame('500円', $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 1); $this->assertTrue(count($violations->get('amount')) === 1); $this->transaction->setAmount(0); $this->assertSame(0, $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 1); $this->assertTrue(count($violations->get('amount')) === 1); $this->transaction->setAmount(-5); $this->assertSame(-5, $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 1); $this->assertTrue(count($violations->get('amount')) === 1); $this->transaction->setAmount(5.5); $this->assertSame(5.5, $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 1); $this->assertTrue(count($violations->get('amount')) === 1); //10 digits is ok. $this->transaction->setAmount(1234567890); $this->assertSame(1234567890, $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 0); //11 digits will cause an overflow. $this->transaction->setAmount(12345678900); $this->assertSame(12345678900, $this->transaction->getAmount()); $violations = Validator::validateMoneyTransferTransaction($this->transaction); $this->assertTrue(count($violations) === 1); $this->assertTrue(count($violations->get('amount')) === 1); }
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 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'); }