菜谱项目

PaymentTest.php 2.2KB

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