public function BrazilianIdsServiceTest::testValidateCpfCnpj in Brazilian IDs 8
Tests validation of CPF or CNPJ depending on value's length.
File
- tests/
src/ Unit/ BrazilianIdsServiceTest.php, line 114
Class
- BrazilianIdsServiceTest
- @coversDefaultClass \Drupal\brazilian_ids\BrazilianIdsService @group brazilian_ids
Namespace
Drupal\Tests\brazilian_ids\UnitCode
public function testValidateCpfCnpj() {
// Valid CPF number.
$this
->assertTrue($this->service
->validateCpfCnpj('29979245883'));
// Valid CNPJ number.
$this
->assertTrue($this->service
->validateCpfCnpj('45598438000151'));
// Invalid CPF number.
$this
->assertFalse($this->service
->validateCpfCnpj('29979245881'));
// Invalid CNPJ number.
$this
->assertFalse($this->service
->validateCpfCnpj('45598438000150'));
// Numbers that do not have either 11 or 14 digits.
$this
->assertFalse($this->service
->validateCpfCnpj('2997924588'));
$this
->assertFalse($this->service
->validateCpfCnpj('299792458833'));
$this
->assertFalse($this->service
->validateCpfCnpj('455984380001512'));
}