From c8c0ce9c2dbbabb55bb21a35e8144d6b285870db Mon Sep 17 00:00:00 2001 From: geekcom Date: Fri, 13 Dec 2019 14:57:03 -0300 Subject: [PATCH] solved: Complexity, update: tests --- CHANGELOG.md | 83 +++++++ src/validator-docs/Rules/Certidao.php | 59 +++++ src/validator-docs/Rules/Cnh.php | 43 ++++ src/validator-docs/Rules/Cnpj.php | 36 +++ src/validator-docs/Rules/Cns.php | 34 +++ src/validator-docs/Rules/Cpf.php | 34 +++ src/validator-docs/Rules/Nis.php | 27 +++ src/validator-docs/Rules/Sanitization.php | 15 ++ src/validator-docs/Rules/TituloEleitoral.php | 65 ++++++ src/validator-docs/Validator.php | 221 +++---------------- tests/TestValidator.php | 47 ++-- 11 files changed, 449 insertions(+), 215 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 src/validator-docs/Rules/Certidao.php create mode 100644 src/validator-docs/Rules/Cnh.php create mode 100644 src/validator-docs/Rules/Cnpj.php create mode 100644 src/validator-docs/Rules/Cns.php create mode 100644 src/validator-docs/Rules/Cpf.php create mode 100644 src/validator-docs/Rules/Nis.php create mode 100644 src/validator-docs/Rules/Sanitization.php create mode 100644 src/validator-docs/Rules/TituloEleitoral.php diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..aad1ff0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,83 @@ + + + + +## Unreleased + +- [#48] added support for changelogs, Thanks to [@geekcom] +- [#45] fixing "Unparenthesized is deprecated" error, Thanks to [@kidh0] +- [#17] fix: erro em phpunit.xml, melhorias nos testes, namespace para testes, Thanks to [@geekcom] +- [#25] Melhorias de leitura nos códigos, Thanks to [@geekcom] +- [#2] Alteração da função validateCnpj para impedir que o Cnpj 00.000.000/0…, Thanks to [@andrergcosta] +- [#3] Criada as funções validateFormatoCpfCnpj e validateCpfCnpj, Thanks to [@andrergcosta] +- [#4] Inclusão do exemplo para validação de CPF/CNPJ no arquivo readme, Thanks to [@andrergcosta] +- [#5] Validar título eleitor, Thanks to [@andrergcosta] +- [#8] Faltando parâmetro $attributes em ValidatorProvider., Thanks to [@setefocos] +- [#11] nova badge e melhoria no readme.me, Thanks to [@geekcom] +- [#12] scrutinizer CI, Thanks to [@geekcom] +- [#19] Criação da função para verificar PIS/PASEP/NIS/NIT, Thanks to [@lordantonelli] +- [#20] Master from develop, Thanks to [@geekcom] +- [#21] Merge pull request [#20] from geekcom/master, Thanks to [@geekcom] +- [#23] update docs, minor corrections, Thanks to [@geekcom] +- [#24] update docs, Thanks to [@geekcom] +- [#30] update scrutinizer CI check, Thanks to [@geekcom] +- [#27] atualizacao para Laravel 6, Thanks to [@geekcom] +- [#47] Merge pull request [#46] from geekcom/master, Thanks to [@geekcom] +- [#31] Atualização dos requisitos e testes, Thanks to [@victorhsanjos] +- [#32] master into develop, Thanks to [@geekcom] +- [#33] Merge pull request [#32] from geekcom/master, Thanks to [@geekcom] +- [#35] auto-discover composer, Thanks to [@geekcom] +- [#37] Adicionando validação do Cartão Nacional de Saúde, Thanks to [@MrEko] +- [#38] Merge, Thanks to [@geekcom] +- [#39] Merge pull request [#38] from geekcom/master, Thanks to [@geekcom] +- [#40] melhorias de documentacao e sintaxe, v3.0.0, Thanks to [@geekcom] +- [#41] Validação de Certidão de Nascimento, Casamento ou Óbito, Thanks to [@MrEko] +- [#42] merge master into develop, Thanks to [@geekcom] +- [#43] Merge pull request [#42] from geekcom/master, Thanks to [@geekcom] +- [#44] melhoria na validacao de CNH,strict_types PHP ativado, Thanks to [@geekcom] +- [#46] merge master inte develop, Thanks to [@geekcom] +- [#1] Update README.md, Thanks to [@yvescabral] + + + +[#48]: https://github.com/geekcom/validator-docs/pull/48 +[#47]: https://github.com/geekcom/validator-docs/pull/47 +[#46]: https://github.com/geekcom/validator-docs/pull/46 +[#45]: https://github.com/geekcom/validator-docs/pull/45 +[#44]: https://github.com/geekcom/validator-docs/pull/44 +[#43]: https://github.com/geekcom/validator-docs/pull/43 +[#42]: https://github.com/geekcom/validator-docs/pull/42 +[#41]: https://github.com/geekcom/validator-docs/pull/41 +[#40]: https://github.com/geekcom/validator-docs/pull/40 +[#39]: https://github.com/geekcom/validator-docs/pull/39 +[#38]: https://github.com/geekcom/validator-docs/pull/38 +[#37]: https://github.com/geekcom/validator-docs/pull/37 +[#35]: https://github.com/geekcom/validator-docs/pull/35 +[#33]: https://github.com/geekcom/validator-docs/pull/33 +[#32]: https://github.com/geekcom/validator-docs/pull/32 +[#31]: https://github.com/geekcom/validator-docs/pull/31 +[#30]: https://github.com/geekcom/validator-docs/pull/30 +[#27]: https://github.com/geekcom/validator-docs/pull/27 +[#25]: https://github.com/geekcom/validator-docs/pull/25 +[#24]: https://github.com/geekcom/validator-docs/pull/24 +[#23]: https://github.com/geekcom/validator-docs/pull/23 +[#21]: https://github.com/geekcom/validator-docs/pull/21 +[#20]: https://github.com/geekcom/validator-docs/pull/20 +[#19]: https://github.com/geekcom/validator-docs/pull/19 +[#17]: https://github.com/geekcom/validator-docs/pull/17 +[#12]: https://github.com/geekcom/validator-docs/pull/12 +[#11]: https://github.com/geekcom/validator-docs/pull/11 +[#8]: https://github.com/geekcom/validator-docs/pull/8 +[#5]: https://github.com/geekcom/validator-docs/pull/5 +[#4]: https://github.com/geekcom/validator-docs/pull/4 +[#3]: https://github.com/geekcom/validator-docs/pull/3 +[#2]: https://github.com/geekcom/validator-docs/pull/2 +[#1]: https://github.com/geekcom/validator-docs/pull/1 +[@yvescabral]: https://github.com/yvescabral +[@victorhsanjos]: https://github.com/victorhsanjos +[@setefocos]: https://github.com/setefocos +[@lordantonelli]: https://github.com/lordantonelli +[@kidh0]: https://github.com/kidh0 +[@geekcom]: https://github.com/geekcom +[@andrergcosta]: https://github.com/andrergcosta +[@MrEko]: https://github.com/MrEko \ No newline at end of file diff --git a/src/validator-docs/Rules/Certidao.php b/src/validator-docs/Rules/Certidao.php new file mode 100644 index 0000000..c08b240 --- /dev/null +++ b/src/validator-docs/Rules/Certidao.php @@ -0,0 +1,59 @@ +sanitize($value); + + if (!preg_match("/[0-9]{32}/", $certidao)) { + return false; + } + + $num = substr($certidao, 0, -2); + $dv = substr($certidao, -2); + + $dv1 = $this->somaPonderadaCertidao($num) % 11; + $dv1 = $dv1 > 9 ? 1 : $dv1; + $dv2 = $this->somaPonderadaCertidao($num.$dv1) % 11; + $dv2 = $dv2 > 9 ? 1 : $dv2; + + // Compara o dv recebido com os dois numeros calculados + if ($dv === $dv1.$dv2) { + return true; + } + + return false; + } + + private function somaPonderadaCertidao($value): int + { + $soma = 0; + + $multiplicador = 32 - mb_strlen($value); + + for ($i = 0; $i < mb_strlen($value); $i++) { + + $soma += $value[$i] * $multiplicador; + + $multiplicador += 1; + $multiplicador = $multiplicador > 10 ? 0 : $multiplicador; + } + + return $soma; + } +} \ No newline at end of file diff --git a/src/validator-docs/Rules/Cnh.php b/src/validator-docs/Rules/Cnh.php new file mode 100644 index 0000000..b759bbd --- /dev/null +++ b/src/validator-docs/Rules/Cnh.php @@ -0,0 +1,43 @@ +sanitize($value); + + if (!is_scalar($value)) { + return false; + } + + if (mb_strlen($value) != 11 || ((int) $value === 0)) { + return false; + } + + for ($c = $s1 = $s2 = 0, $p = 9; $c < 9; $c++, $p--) { + $s1 += (int) $value[$c] * $p; + $s2 += (int) $value[$c] * (10 - $p); + } + + $dv1 = $s1 % 11; + if ($value[9] != ($dv1 > 9) ? 0 : $dv1) { + return false; + } + + $dv2 = $s2 % 11 - ($dv1 > 9 ? 2 : 0); + + $check = $dv2 < 0 ? $dv2 + 11 : ($dv2 > 9 ? 0 : $dv2); + + return $value[10] == $check; + } +} \ No newline at end of file diff --git a/src/validator-docs/Rules/Cnpj.php b/src/validator-docs/Rules/Cnpj.php new file mode 100644 index 0000000..476208f --- /dev/null +++ b/src/validator-docs/Rules/Cnpj.php @@ -0,0 +1,36 @@ +sanitize($value); + + if (mb_strlen($c) != 14 || preg_match("/^{$c[0]}{14}$/", $c)) { + return false; + } + + $b = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]; + + for ($i = 0, $n = 0; $i < 12; $n += $c[$i] * $b[++$i]); + + if ($c[12] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { + return false; + } + + for ($i = 0, $n = 0; $i <= 12; $n += $c[$i] * $b[$i++]); + + if ($c[13] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/src/validator-docs/Rules/Cns.php b/src/validator-docs/Rules/Cns.php new file mode 100644 index 0000000..56f8423 --- /dev/null +++ b/src/validator-docs/Rules/Cns.php @@ -0,0 +1,34 @@ +sanitize($value); + + // CNSs definitivos começam em 1 ou 2 / CNSs provisórios em 7, 8 ou 9 + if (preg_match("/[1-2][0-9]{10}00[0-1][0-9]/", $cns) || preg_match("/[7-9][0-9]{14}/", $cns)) { + return $this->somaPonderadaCns($cns) % 11 == 0; + } + + return false; + } + + private function somaPonderadaCns($value): int + { + $soma = 0; + + for ($i = 0; $i < mb_strlen($value); $i++) { + $soma += $value[$i] * (15 - $i); + } + + return $soma; + } +} \ No newline at end of file diff --git a/src/validator-docs/Rules/Cpf.php b/src/validator-docs/Rules/Cpf.php new file mode 100644 index 0000000..1e9b7c4 --- /dev/null +++ b/src/validator-docs/Rules/Cpf.php @@ -0,0 +1,34 @@ +sanitize($value); + + if (mb_strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) { + return false; + } + + for ($s = 10, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--); + + if ($c[9] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { + return false; + } + + for ($s = 11, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--); + + if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/src/validator-docs/Rules/Nis.php b/src/validator-docs/Rules/Nis.php new file mode 100644 index 0000000..1d4d207 --- /dev/null +++ b/src/validator-docs/Rules/Nis.php @@ -0,0 +1,27 @@ +sanitize($value)); + + if (mb_strlen($nis) != 11 || preg_match("/^{$nis[0]}{11}$/", $nis)) { + return false; + } + + for ($d = 0, $p = 2, $c = 9; $c >= 0; $c--, ($p < 9) ? $p++ : $p = 2) { + $d += $nis[$c] * $p; + } + + return ($nis[10] == (((10 * $d) % 11) % 10)); + } +} \ No newline at end of file diff --git a/src/validator-docs/Rules/Sanitization.php b/src/validator-docs/Rules/Sanitization.php new file mode 100644 index 0000000..d3461f0 --- /dev/null +++ b/src/validator-docs/Rules/Sanitization.php @@ -0,0 +1,15 @@ +sanitize($value); + + $uf = substr($input, -4, 2); + + if (((mb_strlen($input) < 5) || (mb_strlen($input) > 13)) || + (str_repeat($input[1], mb_strlen($input)) == $input) || + ($uf < 1 || $uf > 28)) { + return false; + } + + $dv = substr($input, -2); + $base = 2; + + $sequencia = substr($input, 0, -4); + + for ($i = 0; $i < 2; $i++) { + $fator = 9; + $soma = 0; + + for ($j = (mb_strlen($sequencia) - 1); $j > -1; $j--) { + $soma += $sequencia[$j] * $fator; + + if ($fator == $base) { + $fator = 10; + } + + $fator--; + } + + $digito = $soma % 11; + + if (($digito == 0) and ($uf < 3)) { + $digito = 1; + } elseif ($digito == 10) { + $digito = 0; + } + + if ($dv[$i] != $digito) { + return false; + } + + switch ($i) { + case '0': + $sequencia = $uf . $digito; + break; + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/validator-docs/Validator.php b/src/validator-docs/Validator.php index a95c962..e92293a 100644 --- a/src/validator-docs/Validator.php +++ b/src/validator-docs/Validator.php @@ -5,13 +5,15 @@ namespace geekcom\ValidatorDocs; use Illuminate\Validation\Validator as BaseValidator; +use geekcom\ValidatorDocs\Rules\TituloEleitoral; +use geekcom\ValidatorDocs\Rules\Cns; +use geekcom\ValidatorDocs\Rules\Nis; +use geekcom\ValidatorDocs\Rules\Cpf; +use geekcom\ValidatorDocs\Rules\Cnpj; +use geekcom\ValidatorDocs\Rules\Cnh; +use geekcom\ValidatorDocs\Rules\Certidao; use function preg_match; -use function preg_replace; -use function mb_strlen; -use function str_repeat; -use function sprintf; -use function substr; /** * @@ -47,229 +49,58 @@ protected function validateFormatoCertidao($attribute, $value): bool protected function validateCpf($attribute, $value): bool { - $c = $this->removeCaracteresNaoNumericos($value); + $cpf = new Cpf(); - if (mb_strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) { - return false; - } - - for ($s = 10, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--); - - if ($c[9] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { - return false; - } - - for ($s = 11, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--); - - if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { - return false; - } - - return true; + return $cpf->validateCpf($attribute, $value); } protected function validateCnpj($attribute, $value): bool { - $c = $this->removeCaracteresNaoNumericos($value); - - if (mb_strlen($c) != 14 || preg_match("/^{$c[0]}{14}$/", $c)) { - return false; - } - - $b = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]; + $cnpj = new Cnpj(); - for ($i = 0, $n = 0; $i < 12; $n += $c[$i] * $b[++$i]); - - if ($c[12] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { - return false; - } - - for ($i = 0, $n = 0; $i <= 12; $n += $c[$i] * $b[$i++]); - - if ($c[13] != ((($n %= 11) < 2) ? 0 : 11 - $n)) { - return false; - } - - return true; + return $cnpj->validateCnpj($attribute, $value); } protected function validateCpfCnpj($attribute, $value): bool { - return ($this->validateCpf($attribute, $value) || $this->validateCnpj($attribute, $value)); + $cpf = new Cpf(); + $cnpj = new Cnpj(); + + return ($cpf->validateCpf($attribute, $value) || $cnpj->validateCnpj($attribute, $value)); } - /** - * Trecho retirado do respect validation - */ protected function validateCnh($attribute, $value): bool { - if (!is_scalar($value)) { - return false; - } - - $value = $this->removeCaracteresNaoNumericos($value); - - if (mb_strlen($value) != 11 || ((int) $value === 0)) { - return false; - } + $cnh = new Cnh(); - for ($c = $s1 = $s2 = 0, $p = 9; $c < 9; $c++, $p--) { - $s1 += (int) $value[$c] * $p; - $s2 += (int) $value[$c] * (10 - $p); - } - - $dv1 = $s1 % 11; - if ($value[9] != ($dv1 > 9) ? 0 : $dv1) { - return false; - } - - $dv2 = $s2 % 11 - ($dv1 > 9 ? 2 : 0); - - $check = $dv2 < 0 ? $dv2 + 11 : ($dv2 > 9 ? 0 : $dv2); - - return $value[10] == $check; + return $cnh->validateCnh($attribute, $value); } protected function validateTituloEleitor($attribute, $value): bool { - $input = $this->removeCaracteresNaoNumericos($value); - - $uf = substr($input, -4, 2); - - if (((mb_strlen($input) < 5) || (mb_strlen($input) > 13)) || - (str_repeat($input[1], mb_strlen($input)) == $input) || - ($uf < 1 || $uf > 28)) { - return false; - } - - $dv = substr($input, -2); - $base = 2; - - $sequencia = substr($input, 0, -4); - - for ($i = 0; $i < 2; $i++) { - $fator = 9; - $soma = 0; - - for ($j = (mb_strlen($sequencia) - 1); $j > -1; $j--) { - $soma += $sequencia[$j] * $fator; - - if ($fator == $base) { - $fator = 10; - } - - $fator--; - } - - $digito = $soma % 11; + $tituloEleitoral = new TituloEleitoral(); - if (($digito == 0) and ($uf < 3)) { - $digito = 1; - } elseif ($digito == 10) { - $digito = 0; - } - - if ($dv[$i] != $digito) { - return false; - } - - switch ($i) { - case '0': - $sequencia = $uf . $digito; - break; - } - } - - return true; + return $tituloEleitoral->validateTituloEleitor($attribute, $value); } protected function validateNis($attribute, $value): bool { - $nis = sprintf('%011s', $this->removeCaracteresNaoNumericos($value)); - - if (mb_strlen($nis) != 11 || preg_match("/^{$nis[0]}{11}$/", $nis)) { - return false; - } + $nis = new Nis(); - for ($d = 0, $p = 2, $c = 9; $c >= 0; $c--, ($p < 9) ? $p++ : $p = 2) { - $d += $nis[$c] * $p; - } - - return ($nis[10] == (((10 * $d) % 11) % 10)); + return $nis->validateNis($attribute, $value); } protected function validateCns($attribute, $value): bool { - $cns = $this->removeCaracteresNaoNumericos($value); - - // CNSs definitivos começam em 1 ou 2 / CNSs provisórios em 7, 8 ou 9 - if (preg_match("/[1-2][0-9]{10}00[0-1][0-9]/", $cns) || preg_match("/[7-9][0-9]{14}/", $cns)) { - return $this->somaPonderadaCns($cns) % 11 == 0; - } + $cns = new Cns(); - return false; + return $cns->validateCns($attribute, $value); } - private function somaPonderadaCns($value): int - { - $soma = 0; - - for ($i = 0; $i < mb_strlen($value); $i++) { - $soma += $value[$i] * (15 - $i); - } - - return $soma; - } - - /* - * CERTIDÃO DE NASCIMENTO/CASAMENTO/ÓBITO - * Fonte: http://ghiorzi.org/DVnew.htm#zc - * - * Nota: se o resto for "10", o DV será "1" - */ protected function validateCertidao($attribute, $value): bool { - $certidao = $this->removeCaracteresNaoNumericos($value); - - if (!preg_match("/[0-9]{32}/", $certidao)) { - return false; - } - - $num = substr($certidao, 0, -2); - $dv = substr($certidao, -2); - - $dv1 = $this->somaPonderadaCertidao($num) % 11; - $dv1 = $dv1 > 9 ? 1 : $dv1; - $dv2 = $this->somaPonderadaCertidao($num.$dv1) % 11; - $dv2 = $dv2 > 9 ? 1 : $dv2; - - // Compara o dv recebido com os dois numeros calculados - if ($dv === $dv1.$dv2) { - return true; - } - - return false; - } - - private function somaPonderadaCertidao($value): int - { - $soma = 0; - - $multiplicador = 32 - mb_strlen($value); + $certidao = new Certidao(); - for ($i = 0; $i < mb_strlen($value); $i++) { - - $soma += $value[$i] * $multiplicador; - - $multiplicador += 1; - $multiplicador = $multiplicador > 10 ? 0 : $multiplicador; - } - - return $soma; - } - - private function removeCaracteresNaoNumericos($value): string - { - return preg_replace('/[^\d]/', '', $value); + return $certidao->validateCertidao($attribute, $value); } -} +} \ No newline at end of file diff --git a/tests/TestValidator.php b/tests/TestValidator.php index 1f7dad6..e1d6a27 100644 --- a/tests/TestValidator.php +++ b/tests/TestValidator.php @@ -6,7 +6,8 @@ final class TestValidator extends ValidatorTestCase { - public function testCpf() + /** @test **/ + public function cpf() { $correct = Validator::make( ['certo' => '094.050.986-59'], @@ -23,7 +24,8 @@ public function testCpf() $this->assertTrue($incorrect->fails()); } - public function testCpfFormato() + /** @test **/ + public function cpfFormato() { $correct = Validator::make( ['certo' => '094.050.986-59'], @@ -40,8 +42,8 @@ public function testCpfFormato() $this->assertTrue($incorrect->fails()); } - - public function testCnpj() + /** @test **/ + public function cnpj() { $correct = Validator::make( ['certo' => '53.084.587/0001-20'], @@ -58,8 +60,8 @@ public function testCnpj() $this->assertTrue($incorrect->fails()); } - - public function testCnpjFormato() + /** @test **/ + public function cnpjFormato() { $correct = Validator::make( ['certo' => '53.084.587/0001-20'], @@ -76,8 +78,8 @@ public function testCnpjFormato() $this->assertTrue($incorrect->fails()); } - - public function testCpfCnpj() + /** @test **/ + public function cpfAndCnpjInTheSameAttribute() { $correct = Validator::make( ['certo' => '53.084.587/0001-20'], @@ -94,8 +96,8 @@ public function testCpfCnpj() $this->assertTrue($incorrect->fails()); } - - public function testCpfCnpjFormato() + /** @test **/ + public function cpfCnpjFormato() { $correct = Validator::make( ['certo' => '094.050.986-59'], @@ -112,8 +114,8 @@ public function testCpfCnpjFormato() $this->assertTrue($incorrect->fails()); } - - public function testCnh() + /** @test **/ + public function cnh() { $correct = Validator::make( ['certo' => '96784547943'], @@ -130,8 +132,8 @@ public function testCnh() $this->assertTrue($incorrect->fails()); } - - public function testTituloEleitor() + /** @test **/ + public function tituloEleitoral() { $correct = Validator::make( ['certo' => '3021260'], @@ -148,7 +150,8 @@ public function testTituloEleitor() $this->assertTrue($incorrect->fails()); } - public function testNis() + /** @test **/ + public function nis() { $correct = Validator::make( ['certo' => '201.73374.34-9'], @@ -165,7 +168,8 @@ public function testNis() $this->assertTrue($incorrect->fails()); } - public function testNisFormato() + /** @test **/ + public function nisFormato() { $correct = Validator::make( ['certo' => '201.73374.34-9'], @@ -182,7 +186,8 @@ public function testNisFormato() $this->assertTrue($incorrect->fails()); } - public function testCns() + /** @test **/ + public function cns() { // Definitiva $correct = Validator::make( @@ -198,7 +203,7 @@ public function testCns() $this->assertTrue($correct->passes()); $this->assertTrue($incorrect->fails()); - // Provisoria + // Provisória $correct = Validator::make( ['certo' => '892 1623 5477 0008'], ['certo' => 'cns'] @@ -213,7 +218,8 @@ public function testCns() $this->assertTrue($incorrect->fails()); } - public function testCertidao() + /** @test **/ + public function certidao() { $correct = Validator::make( ['certo' => '659447 02 55 9015 1 99679 468 2559590-16'], @@ -229,7 +235,8 @@ public function testCertidao() $this->assertTrue($incorrect->fails()); } - public function testCertidaoFormato() + /** @test **/ + public function certidaoFormato() { $correct = Validator::make( ['certo' => '434546.02.55.2019.1.71037.134.6484858-10'],