Skip to content

Commit 9cfc88a

Browse files
committed
testes cnpj alfanumérico e ajustes
1 parent 3e35521 commit 9cfc88a

22 files changed

Lines changed: 677 additions & 72 deletions

src/Elements/Z77.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class Z77 extends Element implements ElementInterface
3535
'format' => '',
3636
'length' => 14
3737
],
38-
'IE' => [
39-
'type' => 'string',
40-
'regex' => '^ISENTO|[0-9]{2,14}$',
41-
'required' => false,
42-
'info' => 'Inscrição estadual do tomador do serviço',
43-
'format' => '',
44-
'length' => 14
38+
'COD_MOD' => [
39+
'type' => 'numeric',
40+
'regex' => '^[0-9]{2}$',
41+
'required' => true,
42+
'info' => 'Código do modelo da nota fiscal',
43+
'format' => 'totalNumber',
44+
'length' => 2
4545
],
4646
'SERIE' => [
4747
'type' => 'string',
@@ -136,7 +136,7 @@ class Z77 extends Element implements ElementInterface
136136
'regex' => '^[0-9]{1,2}$',
137137
'required' => true,
138138
'info' => 'Alíquota do ICMS (valor inteiro)',
139-
'format' => 'aliquota',
139+
'format' => 'totalNumber',
140140
'length' => 2
141141
],
142142
'CNPJ_MF' => [

tests/.gitkeep

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/Block1Test.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace NFePHP\Sintegra\Tests;
4+
5+
use NFePHP\Sintegra\Blocks\Block1;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class Block1Test extends TestCase
9+
{
10+
public function testBlock1Success(): void
11+
{
12+
$b1 = new Block1();
13+
14+
$std = new \stdClass();
15+
$std->cNPJ = '77774523000110';
16+
$std->IE = null;
17+
$std->NOME_CONTRIBUINTE = 'FULANO DE TAL LTDA';
18+
$std->MUNICIPIO = 'BREJO SECO';
19+
$std->UF = 'MA';
20+
$std->FAX = null;
21+
$std->DT_INI = '20210101';
22+
$std->DT_FIM = '20210131';
23+
$std->COGIGO_MAGNETICO = '1';
24+
$std->COGIGO_NATUREZAS = '3';
25+
$std->COGIGO_FINALIDADE = '1';
26+
$b1->z10($std);
27+
28+
$std = new \stdClass();
29+
$std->LOGRADOURO = 'RUA DO OUVIDOR';
30+
$std->NUMERO = '100';
31+
$std->COMPLEMENTO = null;
32+
$std->BAIRRO = '';
33+
$std->CEP = '12345678';
34+
$std->CONTATO = 'FULANO DE TAL';
35+
$std->TELEFONE = '5555555';
36+
$b1->z11($std);
37+
38+
$bloco = $b1->get();
39+
40+
$expected = "1077774523000110 FULANO DE TAL LTDA BREJO SECO MA00000000002021010120210131131\r\n"
41+
. "11RUA DO OUVIDOR 00100 12345678FULANO DE TAL 000005555555\r\n";
42+
43+
$this->assertEquals($expected, $bloco);
44+
}
45+
}
Lines changed: 19 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<?php
22

3-
namespace NFePHP\Sintegra\Tests;
3+
namespace NFePHP\Sintegra\Tests\Elements;
44

5+
use NFePHP\Sintegra\Elements\Z10;
56
use PHPUnit\Framework\TestCase;
67

7-
class Bloco1Test extends TestCase
8+
class Z10Test extends TestCase
89
{
9-
public function testZ10CNPJSuccess()
10+
public function testZ10CnpjSuccess(): void
1011
{
1112
$std = new \stdClass();
12-
$std->cNPJ = '77774523000110';
13+
$std->CNPJ = '77774523000110';
1314
$std->IE = null;
1415
$std->NOME_CONTRIBUINTE = 'FULANO DE TAL LTDA';
1516
$std->MUNICIPIO = 'BREJO SECO';
@@ -21,18 +22,18 @@ public function testZ10CNPJSuccess()
2122
$std->COGIGO_NATUREZAS = '3';
2223
$std->COGIGO_FINALIDADE = '1';
2324

24-
$elem = new \NFePHP\Sintegra\Elements\Z10($std);
25+
$elem = new Z10($std);
2526
$got = "{$elem}";
2627
$expected = '1077774523000110 FULANO DE TAL LTDA BREJO SECO MA00000000002021010120210131131';
2728

2829
$this->assertEquals($expected, $got);
2930
$this->assertEquals($elem->errors, []);
3031
}
3132

32-
public function testZ10CPFSuccess()
33+
public function testZ10CpfSuccess(): void
3334
{
3435
$std = new \stdClass();
35-
$std->cNPJ = '50795722052';
36+
$std->CNPJ = '50795722052';
3637
$std->IE = null;
3738
$std->NOME_CONTRIBUINTE = 'FULANO DE TAL LTDA';
3839
$std->MUNICIPIO = 'BREJO SECO';
@@ -44,18 +45,18 @@ public function testZ10CPFSuccess()
4445
$std->COGIGO_NATUREZAS = '3';
4546
$std->COGIGO_FINALIDADE = '1';
4647

47-
$elem = new \NFePHP\Sintegra\Elements\Z10($std);
48+
$elem = new Z10($std);
4849
$got = "{$elem}";
4950
$expected = '1000050795722052 FULANO DE TAL LTDA BREJO SECO MA00000000002021010120210131131';
5051

5152
$this->assertEquals($expected, $got);
5253
$this->assertEquals($elem->errors, []);
5354
}
5455

55-
public function testZ10Fail()
56+
public function testZ10InvalidCnpj(): void
5657
{
5758
$std = new \stdClass();
58-
$std->cNPJ = '777745230';
59+
$std->CNPJ = '777745230';
5960
$std->IE = null;
6061
$std->NOME_CONTRIBUINTE = 'FULANO DE TAL LTDA';
6162
$std->MUNICIPIO = 'BREJO SECO';
@@ -67,7 +68,7 @@ public function testZ10Fail()
6768
$std->COGIGO_NATUREZAS = '3';
6869
$std->COGIGO_FINALIDADE = '1';
6970

70-
$elem = new \NFePHP\Sintegra\Elements\Z10($std);
71+
$elem = new Z10($std);
7172
$got = "{$elem}";
7273
$expected = '1000000777745230 FULANO DE TAL LTDA BREJO SECO MA00000000002021010120210131131';
7374
$this->assertEquals($expected, $got);
@@ -77,44 +78,10 @@ public function testZ10Fail()
7778
$this->assertEquals($elem->errors[1]->message, $message);
7879
}
7980

80-
public function testZ11Success()
81+
public function testBuildWithAlphanumericCnpj(): void
8182
{
8283
$std = new \stdClass();
83-
$std->LOGRADOURO = 'RUA DO OUVIDOR';
84-
$std->NUMERO = '100';
85-
$std->COMPLEMENTO = null;
86-
$std->BAIRRO = '';
87-
$std->CEP = '12345678';
88-
$std->CONTATO = 'FULANO DE TAL';
89-
$std->TELEFONE = '5555555';
90-
$elem = new \NFePHP\Sintegra\Elements\Z11($std);
91-
$got = "{$elem}";
92-
$expected = '11RUA DO OUVIDOR 00100 12345678FULANO DE TAL 000005555555';
93-
$this->assertEquals($expected, $got);
94-
}
95-
96-
public function testZ11Fail()
97-
{
98-
$std = new \stdClass();
99-
$std->LOGRADOURO = 'RUA DO OUVIDOR';
100-
$std->NUMERO = '100';
101-
$std->COMPLEMENTO = null;
102-
$std->BAIRRO = '';
103-
//$std->CEP = '12345678';
104-
$std->CONTATO = 'FULANO DE TAL';
105-
$std->TELEFONE = '5555555';
106-
$elem = new \NFePHP\Sintegra\Elements\Z11($std);
107-
$got = "{$elem}";
108-
$expected = '11RUA DO OUVIDOR 00100 00000000FULANO DE TAL 000005555555';
109-
$this->assertEquals($expected, $got);
110-
$this->assertNotEmpty($elem->errors);
111-
}
112-
113-
public function testBlocoSuccess()
114-
{
115-
$b1 = new \NFePHP\Sintegra\Blocks\Block1();
116-
$std = new \stdClass();
117-
$std->cNPJ = '77774523000110';
84+
$std->CNPJ = 'NLG6401C000144';
11885
$std->IE = null;
11986
$std->NOME_CONTRIBUINTE = 'FULANO DE TAL LTDA';
12087
$std->MUNICIPIO = 'BREJO SECO';
@@ -125,23 +92,12 @@ public function testBlocoSuccess()
12592
$std->COGIGO_MAGNETICO = '1';
12693
$std->COGIGO_NATUREZAS = '3';
12794
$std->COGIGO_FINALIDADE = '1';
128-
$b1->z10($std);
129-
130-
$std = new \stdClass();
131-
$std->LOGRADOURO = 'RUA DO OUVIDOR';
132-
$std->NUMERO = '100';
133-
$std->COMPLEMENTO = null;
134-
$std->BAIRRO = '';
135-
$std->CEP = '12345678';
136-
$std->CONTATO = 'FULANO DE TAL';
137-
$std->TELEFONE = '5555555';
138-
$b1->z11($std);
13995

140-
$bloco = $b1->get();
141-
142-
$expected = "1077774523000110 FULANO DE TAL LTDA BREJO SECO MA00000000002021010120210131131\r\n"
143-
. "11RUA DO OUVIDOR 00100 12345678FULANO DE TAL 000005555555\r\n";
96+
$elem = new Z10($std);
97+
$got = "{$elem}";
98+
$expected = '10NLG6401C000144 FULANO DE TAL LTDA BREJO SECO MA00000000002021010120210131131';
14499

145-
$this->assertEquals($expected, $bloco);
100+
$this->assertEquals($expected, $got);
101+
$this->assertEquals($elem->errors, []);
146102
}
147103
}

tests/Elements/Z11Test.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace NFePHP\Sintegra\Tests\Elements;
4+
5+
use NFePHP\Sintegra\Elements\Z11;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class Z11Test extends TestCase
9+
{
10+
public function testZ11Success(): void
11+
{
12+
$std = new \stdClass();
13+
$std->LOGRADOURO = 'RUA DO OUVIDOR';
14+
$std->NUMERO = '100';
15+
$std->COMPLEMENTO = null;
16+
$std->BAIRRO = '';
17+
$std->CEP = '12345678';
18+
$std->CONTATO = 'FULANO DE TAL';
19+
$std->TELEFONE = '5555555';
20+
$elem = new Z11($std);
21+
$got = "{$elem}";
22+
$expected = '11RUA DO OUVIDOR 00100 12345678FULANO DE TAL 000005555555';
23+
$this->assertEquals($expected, $got);
24+
}
25+
26+
public function testZ11MissingCep(): void
27+
{
28+
$std = new \stdClass();
29+
$std->LOGRADOURO = 'RUA DO OUVIDOR';
30+
$std->NUMERO = '100';
31+
$std->COMPLEMENTO = null;
32+
$std->BAIRRO = '';
33+
$std->CONTATO = 'FULANO DE TAL';
34+
$std->TELEFONE = '5555555';
35+
$elem = new Z11($std);
36+
$got = "{$elem}";
37+
$expected = '11RUA DO OUVIDOR 00100 00000000FULANO DE TAL 000005555555';
38+
$this->assertEquals($expected, $got);
39+
$this->assertNotEmpty($elem->errors);
40+
}
41+
}

tests/Elements/Z50Test.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace NFePHP\Sintegra\Tests\Elements;
4+
5+
use NFePHP\Sintegra\Elements\Z50;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class Z50Test extends TestCase
9+
{
10+
public function testBuildWithAlphanumericCnpj(): void
11+
{
12+
$std = new \stdClass();
13+
$std->CNPJ = 'NLG6401C000144';
14+
$std->IE = '283305054';
15+
$std->DATA_EMISSAO = '20050502';
16+
$std->UF = 'SC';
17+
$std->COD_MOD = '55';
18+
$std->SERIE = '9';
19+
$std->NUM_DOC = '612047';
20+
$std->CFOP = '6102';
21+
$std->EMITENTE = 'P';
22+
$std->VL_TOTAL = 300.2223;
23+
$std->VL_BC_ICMS = 300.594;
24+
$std->VL_ICMS = 24.393939;
25+
$std->ISENTA_NTRIBUTADA = 0;
26+
$std->OUTRAS = 0;
27+
$std->ALIQUOTA = 18;
28+
$std->SITUACAO = 'N';
29+
30+
$elem = new Z50($std);
31+
$got = "{$elem}";
32+
$expected = '50NLG6401C000144283305054 20050502SC559 6120476102P000000003002200000000300590000000002439000000000000000000000000001800N';
33+
34+
$this->assertEquals($expected, $got);
35+
$this->assertEquals($elem->errors, []);
36+
}
37+
}

tests/Elements/Z51Test.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace NFePHP\Sintegra\Tests\Elements;
4+
5+
use NFePHP\Sintegra\Elements\Z51;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class Z51Test extends TestCase
9+
{
10+
public function testBuildWithAlphanumericCnpj(): void
11+
{
12+
$std = new \stdClass();
13+
$std->CNPJ = 'NLG6401C000144';
14+
$std->IE = '283305054';
15+
$std->DATA_EMISSAO = '20050502';
16+
$std->UF = 'SC';
17+
$std->SERIE = '099';
18+
$std->NUM_DOC = '612047';
19+
$std->CFOP = '6102';
20+
$std->VL_TOTAL = 300.00;
21+
$std->VL_TOTAL_IPI = 30.00;
22+
$std->ISENTA_NTRIBUTADA = 0;
23+
$std->OUTRAS = 0;
24+
$std->SITUACAO = 'N';
25+
26+
$elem = new Z51($std);
27+
$got = "{$elem}";
28+
$expected = '51NLG6401C000144283305054 20050502SC09961204761020000000030000000000000300000000000000000000000000000 N';
29+
30+
$this->assertEquals($expected, $got);
31+
$this->assertEquals($elem->errors, []);
32+
}
33+
}

tests/Elements/Z53Test.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace NFePHP\Sintegra\Tests\Elements;
4+
5+
use NFePHP\Sintegra\Elements\Z53;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class Z53Test extends TestCase
9+
{
10+
public function testBuildWithAlphanumericCnpj(): void
11+
{
12+
$std = new \stdClass();
13+
$std->CNPJ = 'NLG6401C000144';
14+
$std->IE = '283305054';
15+
$std->DATA_EMISSAO = '20050502';
16+
$std->UF = 'SC';
17+
$std->COD_MOD = '55';
18+
$std->SERIE = '099';
19+
$std->NUM_DOC = '612047';
20+
$std->CFOP = '6102';
21+
$std->EMITENTE = 'P';
22+
$std->VL_BC_ICMS_ST = 300.00;
23+
$std->VL_ICMS_RET = 30.00;
24+
$std->DESPESAS = 0;
25+
$std->SITUACAO = 'N';
26+
$std->CODIGO_ANTECIPACAO = '1';
27+
28+
$elem = new Z53($std);
29+
$got = "{$elem}";
30+
$expected = '53NLG6401C000144283305054 20050502SC550996120476102P000000003000000000000030000000000000000N1 ';
31+
32+
$this->assertEquals($expected, $got);
33+
$this->assertEquals($elem->errors, []);
34+
}
35+
}

0 commit comments

Comments
 (0)