TCNoTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Faker\Test\Calculator;
  3. use Faker\Calculator\TCNo;
  4. use PHPUnit\Framework\TestCase;
  5. class TCNoTest extends TestCase
  6. {
  7. public function checksumProvider()
  8. {
  9. return array(
  10. array('553006348', '82'),
  11. array('350630743', '78'),
  12. array('550600932', '88'),
  13. array('487932947', '70'),
  14. array('168113862', '40')
  15. );
  16. }
  17. /**
  18. * @dataProvider checksumProvider
  19. * @param $tcNo
  20. * @param $checksum
  21. */
  22. public function testChecksum($tcNo, $checksum)
  23. {
  24. $this->assertEquals($checksum, TCNo::checksum($tcNo), $tcNo);
  25. }
  26. public function validatorProvider()
  27. {
  28. return array(
  29. array('22978160678', true),
  30. array('26480045324', true),
  31. array('47278360658', true),
  32. array('34285002510', true),
  33. array('19874561012', true),
  34. array('11111111111', false),
  35. array('11234567899', false),
  36. );
  37. }
  38. /**
  39. * @dataProvider validatorProvider
  40. * @param $tcNo
  41. * @param $isValid
  42. */
  43. public function testIsValid($tcNo, $isValid)
  44. {
  45. $this->assertEquals($isValid, TCNo::isValid($tcNo), $tcNo);
  46. }
  47. }