From 5b841edb2fffe049895fe6572f68e4ae006216dd Mon Sep 17 00:00:00 2001 From: wallacemaxters Date: Fri, 12 May 2023 17:34:09 -0300 Subject: [PATCH] pequenos ajustes --- .github/workflows/php.yml | 13 +++++-- .gitignore | 1 + tests/TestValidator.php | 81 ++++++++++++++++++++------------------- tests/coverage/.gitignore | 2 + 4 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 tests/coverage/.gitignore diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c460379..e2991e6 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,14 +2,19 @@ name: PHP Composer on: push: - branches: [ master ] + branches: [ master, dev ] pull_request: branches: [ master ] jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + # operating-system: [ubuntu-latest, windows-latest, macOS-latest] + operating-system: [ubuntu-latest] + php-versions: ['7.2', '7.3', '7.4', '8.0'] steps: - uses: actions/checkout@v2 @@ -28,6 +33,6 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress - + - name: Run test suite - run: composer test + run: composer test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 855a2e9..0d45ce6 100755 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.lock pt-br-validator.sublime-project pt-br-validator.sublime-workspace /.phpintel/ +.phpunit.cache/ \ No newline at end of file diff --git a/tests/TestValidator.php b/tests/TestValidator.php index fa6fbf3..7b0efd3 100755 --- a/tests/TestValidator.php +++ b/tests/TestValidator.php @@ -1,22 +1,23 @@ '(99)3500-4444'], ['certo' => 'telefone-com-ddd'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '(99)9-1926'], ['errado' => 'telefone-com-ddd'] ); @@ -28,12 +29,12 @@ public function testTelefoneComDdd() public function testTelefoneComCodigo() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '+55(99)3500-4444'], ['certo' => 'telefone-com-codigo'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '+5(99)9-1926'], ['errado' => 'telefone-com-codigo'] ); @@ -45,12 +46,12 @@ public function testTelefoneComCodigo() public function testCelularComDdd() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '(99)98899-4444'], ['certo' => 'celular-com-ddd'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '(99)800-1926'], ['errado' => 'celular-com-ddd'] ); @@ -62,12 +63,12 @@ public function testCelularComDdd() public function testCelularComCodigo() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '+55(99)98899-4444'], ['certo' => 'celular-com-codigo'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '+5(99)800-1926'], ['errado' => 'celular-com-codigo'] ); @@ -80,12 +81,12 @@ public function testCelularComCodigo() public function testCelular() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '98899-4444', 'outro_certo' => '9800-1936'], ['certo' => 'celular', 'outro_certo' => 'celular'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '900-1926'], ['errado' => 'celular'] ); @@ -97,12 +98,12 @@ public function testCelular() public function testTelefone() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '3598-4550'], ['certo' => 'telefone'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '99800-1926'], ['errado' => 'telefone'] ); @@ -115,12 +116,12 @@ public function testTelefone() public function testCpf() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '094.050.986-59'], ['certo' => 'cpf'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '99800-1926'], ['errado' => 'cpf'] ); @@ -132,12 +133,12 @@ public function testCpf() public function testCpfFormato() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '094.050.986-59'], ['certo' => 'formato-cpf'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '094.050.986-591'], ['errado' => 'formato-cpf'] ); @@ -150,12 +151,12 @@ public function testCpfFormato() public function testCnpj() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '53.084.587/0001-20'], ['certo' => 'cnpj'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '51.084.587/0001-20'], ['errado' => 'cnpj'] ); @@ -177,7 +178,7 @@ public function testCnpj() ]; foreach ($repeats as $cnpj) { - $validator = \Validator::make(['cnpj' => $cnpj], [ + $validator = Validator::make(['cnpj' => $cnpj], [ 'cnpj' => 'required|cnpj' ]); @@ -188,12 +189,12 @@ public function testCnpj() public function testCnpjFormato() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '53.084.587/0001-20'], ['certo' => 'formato-cnpj'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '51.084.587/000120'], ['errado' => 'formato-cnpj'] ); @@ -205,12 +206,12 @@ public function testCnpjFormato() public function testCnh() { - $correct = \Validator::make( + $correct = Validator::make( ['certo' => '96784547943'], ['certo' => 'cnh'] ); - $incorrect = \Validator::make( + $incorrect = Validator::make( ['errado' => '96784547999'], ['errado' => 'cnh'] ); @@ -232,7 +233,7 @@ public function testFormatoCep() foreach ($cepsValidos as $cep) { - $correct = \Validator::make(['cep' => $cep], ['cep' => 'formato_cep']); + $correct = Validator::make(['cep' => $cep], ['cep' => 'formato_cep']); $this->assertTrue($correct->passes()); } @@ -247,7 +248,7 @@ public function testFormatoCep() foreach ($cepsInvalidos as $cep) { - $correct = \Validator::make(['cep' => $cep], ['cep' => 'formato_cep']); + $correct = Validator::make(['cep' => $cep], ['cep' => 'formato_cep']); $this->assertTrue($correct->fails()); } @@ -269,7 +270,7 @@ public function testFormatoPlacaDeVeiculo() ]; foreach ($placasValidas as $placa) { - $correct = \Validator::make( + $correct = Validator::make( ['placa' => $placa], ['placa' => 'formato_placa_de_veiculo'] ); @@ -290,7 +291,7 @@ public function testFormatoPlacaDeVeiculo() ]; foreach ($placasInvalidas as $placa) { - $incorrect = \Validator::make( + $incorrect = Validator::make( ['placa' => $placa], ['placa' => 'formato_placa_de_veiculo'] ); @@ -303,11 +304,11 @@ public function testFormatoPlacaDeVeiculo() public function testFormatoPis() { - $validator = \Validator::make(['valido' => '276.96730.83-0'], [ 'valido' => 'formato_pis' ]); + $validator = Validator::make(['valido' => '276.96730.83-0'], [ 'valido' => 'formato_pis' ]); $this->assertTrue($validator->passes()); - $validator = \Validator::make(['valido' => '276.96730.830'], [ 'valido' => 'formato_pis' ]); + $validator = Validator::make(['valido' => '276.96730.830'], [ 'valido' => 'formato_pis' ]); $this->assertTrue($validator->fails()); } @@ -316,13 +317,13 @@ public function testFormatoPis() public function testPis() { foreach (['690.30244.88-6', '042.33768.05-2', '971.78508.77-5'] as $pis) { - $validator = \Validator::make(['valido' => $pis], [ 'valido' => 'pis']); + $validator = Validator::make(['valido' => $pis], [ 'valido' => 'pis']); $this->assertTrue($validator->passes()); } - $validator = \Validator::make(['valido' => '290.30244.88-5'], [ 'valido' => 'pis' ]); + $validator = Validator::make(['valido' => '290.30244.88-5'], [ 'valido' => 'pis' ]); $this->assertTrue($validator->fails()); } @@ -330,7 +331,7 @@ public function testPis() public function testCpfOuCnpj() { foreach (['981.366.228-09', '56.611.605/0001-73', '49851807000127'] as $valor) { - $validator = \Validator::make( + $validator = Validator::make( ['valido' => $valor], ['valido' => 'cpf_ou_cnpj'] ); @@ -339,7 +340,7 @@ public function testCpfOuCnpj() } foreach (['000.366.228-09', '11.611.605/0001-73', '22851807000127'] as $valor) { - $validator = \Validator::make( + $validator = Validator::make( ['invalido' => $valor], ['invalido' => 'cpf_ou_cnpj'] ); @@ -352,7 +353,7 @@ public function testCpfOuCnpj() public function testFormatoCpfOuCnpj() { foreach (['981.366.228-09', '000.000.000-00', '56.611.605/0001-73'] as $valor) { - $validator = \Validator::make( + $validator = Validator::make( ['valido' => $valor], ['valido' => 'formato_cpf_ou_cnpj'] ); @@ -361,7 +362,7 @@ public function testFormatoCpfOuCnpj() } foreach (['0000.366.228-09', '11.6211.605/0001-73', '22851807000127'] as $valor) { - $validator = \Validator::make( + $validator = Validator::make( ['invalido' => $valor], ['invalido' => 'formato_cpf_ou_cnpj'] ); @@ -409,7 +410,7 @@ public function testUf() ]; foreach ($testes as $valor => $boolean) { - $validator = \Validator::make( + $validator = Validator::make( ['valido' => $valor], ['valido' => 'uf'] ); @@ -431,7 +432,7 @@ public function testCns() '773398431180002', ] as $valor) { - $validator = \Validator::make( + $validator = Validator::make( ['valido' => $valor], ['valido' => ['required', 'cns']] ); @@ -449,7 +450,7 @@ public function testCns() ] as $valor) { - $validator = \Validator::make( + $validator = Validator::make( ['valido' => $valor], ['valido' => ['required', 'cns']] ); diff --git a/tests/coverage/.gitignore b/tests/coverage/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/tests/coverage/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file