Ejemplo n.º 1
0
 /**
  * test the ssn method of BrValidation
  *
  * @return void
  */
 public function testSsn()
 {
     // Testing CPF
     $this->assertFalse(BrValidation::cpf('22692173811'));
     $this->assertFalse(BrValidation::cpf('50549727322'));
     $this->assertFalse(BrValidation::cpf('869.283.422-11'));
     $this->assertFalse(BrValidation::cpf('843.701.734-22'));
     $this->assertFalse(BrValidation::cpf('999.999.999-99'));
     $this->assertTrue(BrValidation::cpf('22692173813'));
     $this->assertTrue(BrValidation::cpf('50549727302'));
     $this->assertTrue(BrValidation::cpf('869.283.422-00'));
     $this->assertTrue(BrValidation::cpf('843.701.734-34'));
     // Testing CNPJ
     $this->assertFalse(BrValidation::cnpj('04295165000133'));
     $this->assertFalse(BrValidation::cnpj('33530485000129'));
     $this->assertFalse(BrValidation::cnpj('04295166000101'));
     $this->assertFalse(BrValidation::cnpj('33530486000130'));
     $this->assertFalse(BrValidation::cnpj('04.295.165/0001-33'));
     $this->assertFalse(BrValidation::cnpj('33.530.485/0001-29'));
     $this->assertFalse(BrValidation::cnpj('04.295.166/0001-01'));
     $this->assertFalse(BrValidation::cnpj('33.530.486/0001-30'));
     $this->assertFalse(BrValidation::cnpj('33.530.48.6/0001-30'));
     $this->assertFalse(BrValidation::cnpj('	33.530.48.6/0001-30 '));
     $this->assertFalse(BrValidation::cnpj('33.530.48.6/000-130'));
     $this->assertTrue(BrValidation::cnpj('04295166000133'));
     $this->assertTrue(BrValidation::cnpj('33530486000129'));
     $this->assertTrue(BrValidation::personId('04.295.166/0001-33'));
     $this->assertTrue(BrValidation::personId('33.530.486/0001-29'));
     // Testing ssn
     $this->assertFalse(BrValidation::personId('04295165000133'));
     $this->assertFalse(BrValidation::personId('33530485000129'));
     $this->assertFalse(BrValidation::personId('04295166000101'));
     $this->assertFalse(BrValidation::personId('33530486000130'));
     $this->assertFalse(BrValidation::personId('04.295.165/0001-33'));
     $this->assertFalse(BrValidation::personId('33.530.485/0001-29'));
     $this->assertFalse(BrValidation::personId('04.295.166/0001-01'));
     $this->assertFalse(BrValidation::personId('33.530.486/0001-30'));
     $this->assertTrue(BrValidation::personId('04295166000133'));
     $this->assertTrue(BrValidation::personId('33530486000129'));
     $this->assertTrue(BrValidation::personId('04.295.166/0001-33'));
     $this->assertTrue(BrValidation::personId('33.530.486/0001-29'));
     // Testing invalid input
     $this->assertFalse(BrValidation::personId('3712093712890371289073901287390812'));
     $this->assertFalse(BrValidation::personId('33aaaa86000129'));
     $this->assertFalse(BrValidation::personId('22692173813xxx'));
     $this->assertFalse(BrValidation::personId('226921xxx73813'));
     $this->assertFalse(BrValidation::personId('11111111111'));
     $this->assertFalse(BrValidation::cpf('abcdefghi'));
 }
Ejemplo n.º 2
0
 /**
  * Checks SSN for Brazil.
  *
  * @param string $check The value to check.
  * @return bool Success.
  */
 public static function personId($check)
 {
     return BrValidation::cpf($check) || BrValidation::cnpj($check);
 }