Skip to content

Commit f9823db

Browse files
authored
Merge pull request #1049 from nfephp-org/testes
Adicionando testes classe Make
2 parents 69d8225 + 52fdd44 commit f9823db

File tree

3 files changed

+237
-0
lines changed

3 files changed

+237
-0
lines changed

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@
3232
<include>
3333
<directory suffix=".php">src</directory>
3434
</include>
35+
<exclude>
36+
<file>src/Common/FakePretty.php</file>
37+
</exclude>
3538
</coverage>
3639
</phpunit>

src/Common/FakePretty.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
1414
* @author Roberto L. Machado <linux.rlm at gmail dot com>
1515
* @link http://github.com/nfephp-org/sped-nfe for the canonical source repository
16+
* @codeCoverageIgnore
1617
*/
1718

1819
class FakePretty

tests/MakeTest.php

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,174 @@ public function test_tagICMS_CST_30(): void
709709
$this->validarCriacaoTagICMS($std);
710710
}
711711

712+
public function test_tagICMS_CST_40(): void
713+
{
714+
$std = new \stdClass();
715+
$std->item = 1;
716+
$std->orig = '0';
717+
$std->CST = '40';
718+
$std->vICMSDeson = '3.60';
719+
$std->motDesICMS = 9;
720+
$std->indDeduzDeson = '0';
721+
722+
$this->validarCriacaoTagICMS($std);
723+
}
724+
725+
public function test_tagICMS_CST_41(): void
726+
{
727+
$std = new \stdClass();
728+
$std->item = 1;
729+
$std->orig = '0';
730+
$std->CST = '41';
731+
$std->vICMSDeson = '3.60';
732+
$std->motDesICMS = 9;
733+
$std->indDeduzDeson = '0';
734+
735+
$this->validarCriacaoTagICMS($std);
736+
}
737+
738+
public function test_tagICMS_CST_50(): void
739+
{
740+
$std = new \stdClass();
741+
$std->item = 1;
742+
$std->orig = '0';
743+
$std->CST = '50';
744+
$std->vICMSDeson = '3.60';
745+
$std->motDesICMS = 9;
746+
$std->indDeduzDeson = '0';
747+
748+
$this->validarCriacaoTagICMS($std);
749+
}
750+
751+
public function test_tagICMS_CST_51(): void
752+
{
753+
$std = new \stdClass();
754+
$std->item = 1;
755+
$std->orig = '0';
756+
$std->CST = '51';
757+
$std->modBC = 3;
758+
$std->pRedBC = 10;
759+
$std->vBC = 100;
760+
$std->pICMS = 17;
761+
$std->vICMSOp = 17;
762+
$std->pDif = 1;
763+
$std->vICMSDif = 1;
764+
$std->vICMS = 17;
765+
$std->vBCFCP = 100;
766+
$std->pFCP = 2;
767+
$std->vFCP = 2;
768+
769+
$this->validarCriacaoTagICMS($std);
770+
}
771+
772+
public function test_tagICMS_CST_53(): void
773+
{
774+
$std = new \stdClass();
775+
$std->item = 1;
776+
$std->orig = '0';
777+
$std->CST = '53';
778+
$std->qBCMono = 200;
779+
$std->adRemICMS = 17;
780+
$std->vICMSMonoOp = 34;
781+
$std->pDif = 1;
782+
$std->vICMSMonoDif = 2;
783+
$std->vICMSMono = 2;
784+
785+
$this->validarCriacaoTagICMS($std);
786+
}
787+
788+
public function test_tagICMS_CST_60(): void
789+
{
790+
$std = new \stdClass();
791+
$std->item = 1;
792+
$std->orig = '0';
793+
$std->CST = '60';
794+
$std->vBCSTRet = 100;
795+
$std->pST = 12;
796+
$std->vICMSSubstituto = 12;
797+
$std->vICMSSTRet = 40;
798+
$std->vBCFCPSTRet = 50;
799+
$std->pFCPSTRet = 10;
800+
$std->vFCPSTRet = 15;
801+
$std->pRedBCEfet = 14;
802+
$std->vBCEfet = 100;
803+
$std->pICMSEfet = 10;
804+
$std->vICMSEfet = 10;
805+
806+
$this->validarCriacaoTagICMS($std);
807+
}
808+
809+
public function test_tagICMS_CST_61(): void
810+
{
811+
$std = new \stdClass();
812+
$std->item = 1;
813+
$std->orig = '0';
814+
$std->CST = '61';
815+
$std->qBCMonoRet = 300;
816+
$std->adRemICMSRet = 2;
817+
$std->vICMSMonoRet = 6;
818+
819+
$this->validarCriacaoTagICMS($std);
820+
}
821+
822+
public function test_tagICMS_CST_70(): void
823+
{
824+
$std = new \stdClass();
825+
$std->item = 1;
826+
$std->orig = '0';
827+
$std->CST = '70';
828+
$std->modBC = 3;
829+
$std->pRedBC = 10;
830+
$std->vBC = 200;
831+
$std->pICMS = 10;
832+
$std->vICMS = 20;
833+
$std->vBCFCP = 200;
834+
$std->pFCP = 2;
835+
$std->vFCP = 4;
836+
$std->modBCST = 4;
837+
$std->pMVAST = 30;
838+
$std->pRedBCST = 0;
839+
$std->vBCST = 60;
840+
$std->pICMSST = 10;
841+
$std->vICMSST = 20;
842+
$std->vBCFCPST = 1;
843+
$std->pFCPST = 1;
844+
$std->vFCPST = 1;
845+
$std->vICMSDeson = 10;
846+
$std->motDesICMS = 9;
847+
848+
$this->validarCriacaoTagICMS($std);
849+
}
850+
851+
public function test_tagICMS_CST_90(): void
852+
{
853+
$std = new \stdClass();
854+
$std->item = 1;
855+
$std->orig = '0';
856+
$std->CST = '90';
857+
$std->modBC = 3;
858+
$std->pRedBC = 10;
859+
$std->vBC = 200;
860+
$std->pICMS = 10;
861+
$std->vICMS = 20;
862+
$std->vBCFCP = 200;
863+
$std->pFCP = 2;
864+
$std->vFCP = 4;
865+
$std->modBCST = 4;
866+
$std->pMVAST = 30;
867+
$std->pRedBCST = 0;
868+
$std->vBCST = 60;
869+
$std->pICMSST = 10;
870+
$std->vICMSST = 20;
871+
$std->vBCFCPST = 1;
872+
$std->pFCPST = 1;
873+
$std->vFCPST = 1;
874+
$std->vICMSDeson = 10;
875+
$std->motDesICMS = 9;
876+
877+
$this->validarCriacaoTagICMS($std);
878+
}
879+
712880
private function validarCriacaoTagICMS(\stdClass $icms): void
713881
{
714882
$attributos = get_object_vars($icms);
@@ -720,6 +888,71 @@ private function validarCriacaoTagICMS(\stdClass $icms): void
720888
}
721889
}
722890

891+
public function test_tagICMSPart(): void
892+
{
893+
$std = new \stdClass();
894+
$std->item = 1;
895+
$std->orig = 0;
896+
$std->CST = '90';
897+
$std->modBC = 1;
898+
$std->vBC = 200;
899+
$std->pRedBC = 5;
900+
$std->pICMS = 10;
901+
$std->vICMS = 20;
902+
$std->modBCST = 4;
903+
$std->pMVAST = 30;
904+
$std->pRedBCST = 0;
905+
$std->vBCST = 60;
906+
$std->pICMSST = 1;
907+
$std->vICMSST = 1;
908+
$std->vBCFCPST = 1;
909+
$std->pFCPST = 1;
910+
$std->vFCPST = 1;
911+
$std->pBCOp = 1;
912+
$std->UFST = 'EX';
913+
$tag = $this->make->tagICMSPart($std);
914+
$tag2 = $tag->getElementsByTagName('ICMSPart')->item(0);
915+
$this->assertEquals('ICMSPart', $tag2->nodeName);
916+
917+
$this->validarExistenciaCampos($std, $tag2);
918+
}
919+
920+
public function test_tagICMSST(): void
921+
{
922+
$std = new \stdClass();
923+
$std->item = 1;
924+
$std->orig = 0;
925+
$std->CST = '41';
926+
$std->vBCSTRet = 200;
927+
$std->vICMSSTRet = 20;
928+
$std->vBCSTDest = 30;
929+
$std->vICMSSTDest = 2;
930+
$std->vBCFCPSTRet = 2;
931+
$std->pFCPSTRet = 2;
932+
$std->vFCPSTRet = 2;
933+
$std->pST = 2;
934+
$std->vICMSSubstituto = 2;
935+
$std->pRedBCEfet = 2;
936+
$std->vBCEfet = 2;
937+
$std->pICMSEfet = 2;
938+
$std->vICMSEfet = 2;
939+
940+
$tag = $this->make->tagICMSST($std);
941+
$tag2 = $tag->getElementsByTagName('ICMSST')->item(0);
942+
$this->assertEquals('ICMSST', $tag2->nodeName);
943+
944+
$this->validarExistenciaCampos($std, $tag2);
945+
}
946+
947+
private function validarExistenciaCampos(\stdClass $std, \DOMElement $tag): void
948+
{
949+
$attributos = get_object_vars($std);
950+
unset($attributos['item']);
951+
foreach ($attributos as $attributo => $valor){
952+
$this->assertEquals($std->{$attributo}, $tag->getElementsByTagName($attributo)->item(0)->nodeValue, "Campo {$attributo} possui valor incorreto!");
953+
}
954+
}
955+
723956

724957
protected function setUp(): void
725958
{

0 commit comments

Comments
 (0)