From 5dfc74a6360b2620f07a13fb1c55fda4e5c835a3 Mon Sep 17 00:00:00 2001 From: Gerson Felipe Schwinn Date: Tue, 28 May 2024 19:44:20 -0300 Subject: [PATCH 1/2] Adicionando mais testes --- tests/MakeTest.php | 100 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/tests/MakeTest.php b/tests/MakeTest.php index bacb2012..5cc8a22d 100755 --- a/tests/MakeTest.php +++ b/tests/MakeTest.php @@ -498,9 +498,9 @@ public function test_tagveicProd(): void $this->assertEquals($std->cCor, $tag->getElementsByTagName('cCor')->item(0)->nodeValue); $this->assertEquals($std->xCor, $tag->getElementsByTagName('xCor')->item(0)->nodeValue); $this->assertEquals($std->pot, $tag->getElementsByTagName('pot')->item(0)->nodeValue); - $this->assertEquals($std->cilin, $tag->getElementsByTagName('cilin')->item(0)->nodeValue); - $this->assertEquals($std->pesoL, $tag->getElementsByTagName('pesoL')->item(0)->nodeValue); - $this->assertEquals($std->pesoB, $tag->getElementsByTagName('pesoB')->item(0)->nodeValue); + $this->assertEquals($std->cilin, $tag->getElementsByTagName('cilin')->item(0)->nodeValue); + $this->assertEquals($std->pesoL, $tag->getElementsByTagName('pesoL')->item(0)->nodeValue); + $this->assertEquals($std->pesoB, $tag->getElementsByTagName('pesoB')->item(0)->nodeValue); $this->assertEquals($std->nSerie, $tag->getElementsByTagName('nSerie')->item(0)->nodeValue); $this->assertEquals($std->tpComb, $tag->getElementsByTagName('tpComb')->item(0)->nodeValue); $this->assertEquals($std->nMotor, $tag->getElementsByTagName('nMotor')->item(0)->nodeValue); @@ -534,7 +534,7 @@ public function test_tagmed(): void $this->assertEquals($std->vPMC, $tag->getElementsByTagName('vPMC')->item(0)->nodeValue); } - public function test_tagarma():void + public function test_tagarma(): void { $std = new \stdClass(); $std->item = 1; @@ -587,6 +587,98 @@ public function test_tagcomb(): void $this->assertEquals($std->vCIDE, $CIDE->getElementsByTagName('vCIDE')->item(0)->nodeValue); } + public function test_tagencerrante(): void + { + $std = new \stdClass(); + $std->item = 1; + $std->nBico = 1; + $std->nBomba = 2; + $std->nTanque = 3; + $std->vEncIni = '100.000'; + $std->vEncFin = '200.000'; + + $tag = $this->make->tagencerrante($std); + $this->assertEquals('encerrante', $tag->nodeName); + $this->assertEquals($std->nBico, $tag->getElementsByTagName('nBico')->item(0)->nodeValue); + $this->assertEquals($std->nBomba, $tag->getElementsByTagName('nBomba')->item(0)->nodeValue); + $this->assertEquals($std->nTanque, $tag->getElementsByTagName('nTanque')->item(0)->nodeValue); + $this->assertEquals($std->vEncIni, $tag->getElementsByTagName('vEncIni')->item(0)->nodeValue); + $this->assertEquals($std->vEncFin, $tag->getElementsByTagName('vEncFin')->item(0)->nodeValue); + } + + public function test_tagorigComb(): void + { + $std = new \stdClass(); + $std->item = 1; + $std->indImport = 1; + $std->cUFOrig = '11'; + $std->pOrig = '200.0000'; + + $tag = $this->make->tagorigComb($std); + $this->assertEquals('origComb', $tag->nodeName); + $this->assertEquals($std->indImport, $tag->getElementsByTagName('indImport')->item(0)->nodeValue); + $this->assertEquals($std->cUFOrig, $tag->getElementsByTagName('cUFOrig')->item(0)->nodeValue); + $this->assertEquals($std->pOrig, $tag->getElementsByTagName('pOrig')->item(0)->nodeValue); + } + + public function test_tagICMS_CST_00(): void + { + $std = new \stdClass(); + $std->item = 1; + $std->orig = '0'; + $std->CST = '00'; + $std->modBC = '3'; + $std->vBC = '200.00'; + $std->pICMS = '18.0000'; + $std->vICMS = '36.00'; + $std->pFCP = '1.0000'; + $std->vFCP = '2.00'; + + $tag = $this->make->tagICMS($std); + $this->assertEquals('ICMS', $tag->nodeName); + $this->assertEquals($std->orig, $tag->getElementsByTagName('orig')->item(0)->nodeValue); + $this->assertEquals($std->CST, $tag->getElementsByTagName('CST')->item(0)->nodeValue); + $this->assertEquals($std->modBC, $tag->getElementsByTagName('modBC')->item(0)->nodeValue); + $this->assertEquals($std->vBC, $tag->getElementsByTagName('vBC')->item(0)->nodeValue); + $this->assertEquals($std->pICMS, $tag->getElementsByTagName('pICMS')->item(0)->nodeValue); + $this->assertEquals($std->vICMS, $tag->getElementsByTagName('vICMS')->item(0)->nodeValue); + $this->assertEquals($std->pFCP, $tag->getElementsByTagName('pFCP')->item(0)->nodeValue); + $this->assertEquals($std->vFCP, $tag->getElementsByTagName('vFCP')->item(0)->nodeValue); + } + + public function test_tagICMS_CST_20(): void + { + $std = new \stdClass(); + $std->item = 1; + $std->orig = '0'; + $std->CST = '20'; + $std->modBC = '3'; + $std->pRedBC = '5.0000'; + $std->vBC = '180.00'; + $std->pICMS = '18.0000'; + $std->vICMS = '32.40'; + $std->vBCFCP = '200.00'; + $std->pFCP = '1.0000'; + $std->vFCP = '2.00'; + $std->vICMSDeson = '3.60'; + $std->motDesICMS = 9; + + $tag = $this->make->tagICMS($std); + $this->assertEquals('ICMS', $tag->nodeName); + $this->assertEquals($std->orig, $tag->getElementsByTagName('orig')->item(0)->nodeValue); + $this->assertEquals($std->CST, $tag->getElementsByTagName('CST')->item(0)->nodeValue); + $this->assertEquals($std->modBC, $tag->getElementsByTagName('modBC')->item(0)->nodeValue); + $this->assertEquals($std->pRedBC, $tag->getElementsByTagName('pRedBC')->item(0)->nodeValue); + $this->assertEquals($std->vBC, $tag->getElementsByTagName('vBC')->item(0)->nodeValue); + $this->assertEquals($std->pICMS, $tag->getElementsByTagName('pICMS')->item(0)->nodeValue); + $this->assertEquals($std->vICMS, $tag->getElementsByTagName('vICMS')->item(0)->nodeValue); + $this->assertEquals($std->vBCFCP, $tag->getElementsByTagName('vBCFCP')->item(0)->nodeValue); + $this->assertEquals($std->pFCP, $tag->getElementsByTagName('pFCP')->item(0)->nodeValue); + $this->assertEquals($std->vFCP, $tag->getElementsByTagName('vFCP')->item(0)->nodeValue); + $this->assertEquals($std->vICMSDeson, $tag->getElementsByTagName('vICMSDeson')->item(0)->nodeValue); + $this->assertEquals($std->motDesICMS, $tag->getElementsByTagName('motDesICMS')->item(0)->nodeValue); + } + protected function setUp(): void { $this->make = new Make(); From f3d7b143b138a472ffbcc44ec472223aadb281c6 Mon Sep 17 00:00:00 2001 From: Gerson Felipe Schwinn Date: Wed, 29 May 2024 09:09:04 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Adicionando=20mais=20CSTs=20e=20refatorando?= =?UTF-8?q?=20l=C3=B3gica=20para=20testar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/MakeTest.php | 88 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 23 deletions(-) diff --git a/tests/MakeTest.php b/tests/MakeTest.php index 5cc8a22d..4f64b18b 100755 --- a/tests/MakeTest.php +++ b/tests/MakeTest.php @@ -634,16 +634,37 @@ public function test_tagICMS_CST_00(): void $std->pFCP = '1.0000'; $std->vFCP = '2.00'; - $tag = $this->make->tagICMS($std); - $this->assertEquals('ICMS', $tag->nodeName); - $this->assertEquals($std->orig, $tag->getElementsByTagName('orig')->item(0)->nodeValue); - $this->assertEquals($std->CST, $tag->getElementsByTagName('CST')->item(0)->nodeValue); - $this->assertEquals($std->modBC, $tag->getElementsByTagName('modBC')->item(0)->nodeValue); - $this->assertEquals($std->vBC, $tag->getElementsByTagName('vBC')->item(0)->nodeValue); - $this->assertEquals($std->pICMS, $tag->getElementsByTagName('pICMS')->item(0)->nodeValue); - $this->assertEquals($std->vICMS, $tag->getElementsByTagName('vICMS')->item(0)->nodeValue); - $this->assertEquals($std->pFCP, $tag->getElementsByTagName('pFCP')->item(0)->nodeValue); - $this->assertEquals($std->vFCP, $tag->getElementsByTagName('vFCP')->item(0)->nodeValue); + $this->validarCriacaoTagICMS($std); + } + + public function test_tagICMS_CST_02(): void + { + $std = new \stdClass(); + $std->item = 1; + $std->orig = '0'; + $std->CST = '02'; + $std->qBCMono = '200.0000'; + $std->adRemICMS = '25.0000'; + $std->vICMSMono = '50.00'; + + $this->validarCriacaoTagICMS($std); + } + public function test_tagICMS_CST_15(): void + { + $std = new \stdClass(); + $std->item = 1; + $std->orig = '0'; + $std->CST = '15'; + $std->qBCMono = '200.0000'; + $std->adRemICMS = '25.0000'; + $std->vICMSMono = '50.00'; + $std->qBCMonoReten = '100.0000'; + $std->adRemICMSReten = '20.0000'; + $std->vICMSMonoReten = '20.00'; + $std->pRedAdRem = '1.00'; + $std->motRedAdRem = '1'; + + $this->validarCriacaoTagICMS($std); } public function test_tagICMS_CST_20(): void @@ -663,22 +684,43 @@ public function test_tagICMS_CST_20(): void $std->vICMSDeson = '3.60'; $std->motDesICMS = 9; - $tag = $this->make->tagICMS($std); + $this->validarCriacaoTagICMS($std); + } + + public function test_tagICMS_CST_30(): void + { + $std = new \stdClass(); + $std->item = 1; + $std->orig = '0'; + $std->CST = '30'; + $std->modBCST = '4'; + $std->pMVAST = '30.0000'; + $std->pRedBCST = '1.0000'; + $std->vBCST = '1.00'; + $std->pICMSST = '1.0000'; + $std->vICMSST = '1.00'; + $std->vBCFCPST = '1.00'; + $std->pFCPST = '1.0000'; + $std->vFCPST = '1.00'; + $std->vICMSDeson = '3.60'; + $std->motDesICMS = 9; + $std->indDeduzDeson = '0'; + + $this->validarCriacaoTagICMS($std); + } + + private function validarCriacaoTagICMS(\stdClass $icms): void + { + $attributos = get_object_vars($icms); + $tag = $this->make->tagICMS($icms); $this->assertEquals('ICMS', $tag->nodeName); - $this->assertEquals($std->orig, $tag->getElementsByTagName('orig')->item(0)->nodeValue); - $this->assertEquals($std->CST, $tag->getElementsByTagName('CST')->item(0)->nodeValue); - $this->assertEquals($std->modBC, $tag->getElementsByTagName('modBC')->item(0)->nodeValue); - $this->assertEquals($std->pRedBC, $tag->getElementsByTagName('pRedBC')->item(0)->nodeValue); - $this->assertEquals($std->vBC, $tag->getElementsByTagName('vBC')->item(0)->nodeValue); - $this->assertEquals($std->pICMS, $tag->getElementsByTagName('pICMS')->item(0)->nodeValue); - $this->assertEquals($std->vICMS, $tag->getElementsByTagName('vICMS')->item(0)->nodeValue); - $this->assertEquals($std->vBCFCP, $tag->getElementsByTagName('vBCFCP')->item(0)->nodeValue); - $this->assertEquals($std->pFCP, $tag->getElementsByTagName('pFCP')->item(0)->nodeValue); - $this->assertEquals($std->vFCP, $tag->getElementsByTagName('vFCP')->item(0)->nodeValue); - $this->assertEquals($std->vICMSDeson, $tag->getElementsByTagName('vICMSDeson')->item(0)->nodeValue); - $this->assertEquals($std->motDesICMS, $tag->getElementsByTagName('motDesICMS')->item(0)->nodeValue); + unset($attributos['item']); + foreach ($attributos as $attributo => $valor){ + $this->assertEquals($icms->{$attributo}, $tag->getElementsByTagName($attributo)->item(0)->nodeValue, "Campo {$attributo} possui valor incorreto!"); + } } + protected function setUp(): void { $this->make = new Make();