isValid() public static method

Checks whether a number (partial number + check digit) is Luhn compliant
public static isValid ( string $number ) : boolean
$number string
return boolean
Ejemplo n.º 1
0
 public function testSirenReturnsAWellFormattedSiren()
 {
     $siren = $this->faker->siren();
     $this->assertRegExp("/^\\d{3}\\s\\d{3}\\s\\d{3}\$/", $siren);
     $siren = str_replace(' ', '', $siren);
     $this->assertTrue(Luhn::isValid($siren));
 }
 public function testImeiReturnsValidNumber()
 {
     $imei = $this->faker->imei();
     $this->assertTrue(Luhn::isValid($imei));
 }
Ejemplo n.º 3
0
 public function testPersonalIdentityNumberGeneratesLuhnCompliantNumbers()
 {
     $pin = str_replace('-', '', $this->faker->personalIdentityNumber());
     $this->assertTrue(Luhn::isValid($pin));
 }
Ejemplo n.º 4
0
 /**
  * @dataProvider validatorProvider
  */
 public function testIsValid($number, $isValid)
 {
     $this->assertEquals($isValid, Luhn::isValid($number));
 }
Ejemplo n.º 5
0
 /**
  * @dataProvider creditCardNumberProvider
  */
 public function testCreditCardNumberReturnsValidCreditCardNumber($type, $regexp)
 {
     $cardNumber = $this->faker->creditCardNumber($type);
     $this->assertRegExp($regexp, $cardNumber);
     $this->assertTrue(Luhn::isValid($cardNumber));
 }