diff --git a/readme.md b/readme.md index 062b329f2f..08fe22e00f 100644 --- a/readme.md +++ b/readme.md @@ -239,7 +239,9 @@ Each of the generator properties (like `name`, `address`, and `lorem`) are calle creditCardDetails // array('MasterCard', '4485480221084675', 'Aleksander Nowak', '04/13') // Generates a random IBAN. Set $countryCode to null for a random country iban($countryCode) // 'IT31A8497112740YZ575DJ28BP4' - swiftBicNumber // RZTIAT22263 + swiftBicNumber // 'RZTIAT22263' + bankAccountNumber // '51915734310' + bankRoutingNumber // '212240302' ### `Faker\Provider\Color` diff --git a/src/Faker/Provider/en_US/Payment.php b/src/Faker/Provider/en_US/Payment.php new file mode 100644 index 0000000000..a4ba79e5fe --- /dev/null +++ b/src/Faker/Provider/en_US/Payment.php @@ -0,0 +1,38 @@ +addProvider(new Payment($faker)); + $this->faker = $faker; + } + + public function testBankAccountNumber() + { + $accNo = $this->faker->bankAccountNumber; + $this->assertTrue(ctype_digit($accNo)); + $this->assertLessThanOrEqual(17, strlen($accNo)); + } + + public function testBankRoutingNumber() + { + $routingNo = $this->faker->bankRoutingNumber; + $this->assertRegExp('/^\d{9}$/', $routingNo); + $this->assertEquals(Payment::calculateRoutingNumberChecksum($routingNo), $routingNo[8]); + } + + public function routingNumberProvider() + { + return array( + array('122105155'), + array('082000549'), + array('121122676'), + array('122235821'), + array('102101645'), + array('102000021'), + array('123103729'), + array('071904779'), + array('081202759'), + array('074900783'), + array('104000029'), + array('073000545'), + array('101000187'), + array('042100175'), + array('083900363'), + array('091215927'), + array('091300023'), + array('091000022'), + array('081000210'), + array('101200453'), + array('092900383'), + array('104000029'), + array('121201694'), + array('107002312'), + array('091300023'), + array('041202582'), + array('042000013'), + array('123000220'), + array('091408501'), + array('064000059'), + array('124302150'), + array('125000105'), + array('075000022'), + array('307070115'), + array('091000022'), + ); + } + + /** + * @dataProvider routingNumberProvider + */ + public function testCalculateRoutingNumberChecksum($routingNo) + { + $this->assertEquals($routingNo[8], Payment::calculateRoutingNumberChecksum($routingNo), $routingNo); + } +}