Skip to content

Commit

Permalink
tests: construct required parent tags
Browse files Browse the repository at this point in the history
  • Loading branch information
lidani committed Jun 7, 2024
1 parent ee09fd1 commit 44920a5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -1842,8 +1842,8 @@ public function tagprod(stdClass $std): DOMElement
$this->errors[] = "cEANTrib {$ceantrib} " . $e->getMessage();
}

$CRT = !empty($this->emit) ? $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null : null;
$idDest = !empty($this->ide) ? $this->ide->getElementsByTagName("idDest")->item(0)->nodeValue ?? null : null;
$CRT = $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null;
$idDest = $this->ide->getElementsByTagName("idDest")->item(0)->nodeValue ?? null;
$allowEmptyNcm = $CRT == 4 && $idDest == 1;

if ($allowEmptyNcm && empty($std->NCM)) {
Expand Down Expand Up @@ -4755,7 +4755,7 @@ public function tagICMSSN(stdClass $std): DOMElement
$this->stdTot->vFCPST += (float) !empty($std->vFCPST) ? $std->vFCPST : 0;
$this->stdTot->vFCPSTRet += (float) !empty($std->vFCPSTRet) ? $std->vFCPSTRet : 0;

$CRT = !empty($this->emit) ? $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null : null;
$CRT = $this->emit->getElementsByTagName("CRT")->item(0)->nodeValue ?? null;
$allowEmptyOrig = $CRT == 4 && in_array($std->CSOSN, [
'102', '103', '300', '400', '900',
]);
Expand Down
33 changes: 33 additions & 0 deletions tests/MakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,9 @@ public function test_tagII(): void

public function test_tagISSQN(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->cProd = '1111';
Expand Down Expand Up @@ -1156,6 +1159,9 @@ public function test_tagICMSST(): void

public function test_tagICMSSN_101(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand All @@ -1173,6 +1179,9 @@ public function test_tagICMSSN_101(): void

public function test_tagICMSSN_102(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand All @@ -1188,6 +1197,9 @@ public function test_tagICMSSN_102(): void

public function test_tagICMSSN_103(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand All @@ -1203,6 +1215,9 @@ public function test_tagICMSSN_103(): void

public function test_tagICMSSN_300(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand All @@ -1218,6 +1233,9 @@ public function test_tagICMSSN_300(): void

public function test_tagICMSSN_400(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand All @@ -1233,6 +1251,9 @@ public function test_tagICMSSN_400(): void

public function test_tagICMSSN_201(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand Down Expand Up @@ -1260,6 +1281,9 @@ public function test_tagICMSSN_201(): void

public function test_tagICMSSN_202(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand All @@ -1284,6 +1308,9 @@ public function test_tagICMSSN_202(): void

public function test_tagICMSSN_203(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand All @@ -1308,6 +1335,9 @@ public function test_tagICMSSN_203(): void

public function test_tagICMSSN_500(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand Down Expand Up @@ -1335,6 +1365,9 @@ public function test_tagICMSSN_500(): void

public function test_tagICMSSN_900(): void
{
$this->make->tagide(new \stdClass());
$this->make->tagemit(new \stdClass());

$std = new \stdClass();
$std->item = 1;
$std->orig = 0;
Expand Down

0 comments on commit 44920a5

Please sign in to comment.