cvs: pear /Payment_DTA/tests DTATest.php DTAZVTest.php

From: Date: Wed, 13 May 2009 17:04:08 +0000
Subject: cvs: pear /Payment_DTA/tests DTATest.php DTAZVTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-56088@lists.php.net to get a copy of this message
mschuett Wed May 13 17:04:08 2009 UTC Modified files: /pear/Payment_DTA/tests DTAZVTest.php DTATest.php Log: add test for DTAZV checksum and new comparison of generated and expected(=reviewed) output http://cvs.php.net/viewvc.cgi/pear/Payment_DTA/tests/DTAZVTest.php?r1=1.5&r2=1.6&diff_format=u Index: pear/Payment_DTA/tests/DTAZVTest.php diff -u pear/Payment_DTA/tests/DTAZVTest.php:1.5 pear/Payment_DTA/tests/DTAZVTest.php:1.6 --- pear/Payment_DTA/tests/DTAZVTest.php:1.5 Thu Feb 26 00:08:02 2009 +++ pear/Payment_DTA/tests/DTAZVTest.php Wed May 13 17:04:08 2009 @@ -14,13 +14,13 @@ { // Create the Array fixture. $this->fixture = new DTAZV(); - $DTAZV_asta_account = array( + $DTAZV_account = array( 'name' => "Senders Name", 'additional_name' => '', 'bank_code' => "16050000", 'account_number' => "3503007767", ); - $this->fixture->setAccountFileSender($DTAZV_asta_account); + $this->fixture->setAccountFileSender($DTAZV_account); } public function testInstantiate() @@ -236,6 +236,34 @@ $this->assertEquals(256+768+768+256, strlen($this->fixture->getFileContent())); } + public function testChecksum() + { + $this->assertTrue($this->fixture->addExchange(array( + 'name' => "A Receivers Name", + 'bank_code' => "MARKDEFF", + 'account_number' => "DE68210501700012345678" + ), + (float) 1234.56, + "Test-Verwendungszweck" + )); + $this->assertTrue($this->fixture->addExchange(array( + 'name' => "A Receivers Name", + 'bank_code' => "RZTIAT22263", + 'account_number' => "DE21700519950000007229" + ), + (float) 1234.56, + "Test-Verwendungszweck" + )); + + /* v1.3.0 incorrectly used the intval(sum) as checksum in field Z03, + * yielding intval(1234.56+1234.56) = 2469 + * The correct calculation is to use the sum of intvals, + * thus intval(1234.56)+intval(1234.56) = 2468 + */ + $content = $this->fixture->getFileContent(); + $this->assertEquals(2468, (int)substr($content, 256+768+768+5, 15)); + } + public function testGermanBLZ() { $this->assertTrue($this->fixture->addExchange(array( @@ -293,6 +321,59 @@ $this->assertFalse($this->fixture->saveFile($tmpfname)); } + public function testContent() + { + $this->assertTrue($this->fixture->addExchange(array( + 'name' => "Receivers Name", + 'bank_code' => "RZTIAT22263", + 'account_number' => "DE21700519950000007229"), + (float) 123.45, + "Test-Verwendungszweck" + )); + $this->assertTrue($this->fixture->addExchange(array( + 'name' => "Second Receivers Name", + 'bank_code' => "RZTIAT22263", + 'account_number' => "DE21700519950000007229"), + (float) 234.56, + "Test2" + )); + + $expected = // 64 chars per line: + '0256Q160500003503007767SENDERS NAME '. + ' '. + ' 13050900130509N0000000000 '. + ' '. + '0768T16050000EUR350300776700000000000000 0000000000RZTIAT22263'. + ' '. + ' '. + ' DE RECEIVERS NAME '. + ' '. + ' '. + ' /DE21700519950000007229 '. + ' EUR00000000000123450TEST-VERWENDUNGSZWECK '. + ' '. + ' 00000000 '. + ' 0013 '. + ' 0 00'. + '0768T16050000EUR350300776700000000000000 0000000000RZTIAT22263'. + ' '. + ' '. + ' DE SECOND RECEIVERS NAME '. + ' '. + ' '. + ' /DE21700519950000007229 '. + ' EUR00000000000234560TEST2 '. + ' '. + ' 00000000 '. + ' 0013 '. + ' 0 00'. + '0256Z000000000000357000000000000002 '. + ' '. + ' '. + ' '; + $this->assertEquals($expected, $this->fixture->getFileContent()); + } + public function testGetMetaData1() { $this->assertTrue($this->fixture->addExchange(array( http://cvs.php.net/viewvc.cgi/pear/Payment_DTA/tests/DTATest.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Payment_DTA/tests/DTATest.php diff -u pear/Payment_DTA/tests/DTATest.php:1.7 pear/Payment_DTA/tests/DTATest.php:1.8 --- pear/Payment_DTA/tests/DTATest.php:1.7 Thu Feb 26 00:08:02 2009 +++ pear/Payment_DTA/tests/DTATest.php Wed May 13 17:04:08 2009 @@ -704,6 +704,41 @@ $this->assertFalse($this->fixture->saveFile($tmpfname)); } + public function testContent() + { + $this->fixture->addExchange(array( + "name" => "Franz Mueller", + "bank_code" => 33334444, + "account_number" => 13579000, + ), + (float) 1234.56, + "Test-Verwendungszweck" + ); + $this->fixture->addExchange(array( + "name" => "Franz Mueller", + "bank_code" => 33334444, + "account_number" => 13579000 + ), + (float) 321.9, + "Test-Verwendungszweck" + ); + + $expected = // 64 chars per line: + '0128AGK1605000000000000SENDERS NAME 130509 3503'. + '0077670000000000 1'. + '0187C16050000333344440013579000000000000000051000 00000000000160'. + '50000350300776700000123456 FRANZ MUELLER '. + 'SENDERS NAME TEST-VERWENDUNGSZWECK 1 00 '. + ' '. + '0187C16050000333344440013579000000000000000051000 00000000000160'. + '50000350300776700000032190 FRANZ MUELLER '. + 'SENDERS NAME TEST-VERWENDUNGSZWECK 1 00 '. + ' '. + '0128E 000000200000000000000000000002715800000000000066668888'. + '0000000155646 '; + $this->assertEquals($expected, $this->fixture->getFileContent()); + } + public function testGetMetaData1() { $this->assertTrue($this->fixture->addExchange(array(

« previous php.pear.cvs (#56088) next »