1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
<?php
namespace Faker\Provider\en_US;
use Faker\Test\TestCase;
/**
* @group legacy
*/
final class PaymentTest extends TestCase
{
public function testBankAccountNumber()
{
$accNo = $this->faker->bankAccountNumber;
self::assertTrue(ctype_digit($accNo));
self::assertLessThanOrEqual(17, strlen($accNo));
}
public function testBankRoutingNumber()
{
$routingNo = $this->faker->bankRoutingNumber;
self::assertMatchesRegularExpression('/^\d{9}$/', $routingNo);
self::assertEquals(Payment::calculateRoutingNumberChecksum($routingNo), $routingNo[8]);
}
public function routingNumberProvider()
{
return [
['122105155'],
['082000549'],
['121122676'],
['122235821'],
['102101645'],
['102000021'],
['123103729'],
['071904779'],
['081202759'],
['074900783'],
['104000029'],
['073000545'],
['101000187'],
['042100175'],
['083900363'],
['091215927'],
['091300023'],
['091000022'],
['081000210'],
['101200453'],
['092900383'],
['104000029'],
['121201694'],
['107002312'],
['091300023'],
['041202582'],
['042000013'],
['123000220'],
['091408501'],
['064000059'],
['124302150'],
['125000105'],
['075000022'],
['307070115'],
['091000022'],
];
}
/**
* @dataProvider routingNumberProvider
*/
public function testCalculateRoutingNumberChecksum($routingNo)
{
self::assertEquals($routingNo[8], Payment::calculateRoutingNumberChecksum($routingNo), $routingNo);
}
protected function getProviders(): iterable
{
yield new Payment($this->faker);
}
}
|