@@ -85,15 +85,13 @@ public function test_calculate_vat_with_predefined_rules_overwritten_by_configur
8585 $ net = 24.00 ;
8686 $ countryCode = 'DE ' ;
8787
88- $ taxKey = 'vat_calculator.rules. ' .strtoupper ($ countryCode );
89-
9088 $ config = m::mock (Repository::class);
9189 $ config ->shouldReceive ('get ' )
9290 ->once ()
9391 ->with ('vat_calculator ' , [])
9492 ->andReturn ([
9593 'rules ' => [
96- ' DE ' => 0.50 ,
94+ $ countryCode => 0.50 ,
9795 ],
9896 ]);
9997
@@ -699,15 +697,13 @@ public function test_postal_codes_without_exceptions_overwritten_by_configuratio
699697 $ net = 24.00 ;
700698 $ countryCode = 'DE ' ;
701699
702- $ taxKey = 'vat_calculator.rules. ' .strtoupper ($ countryCode );
703-
704700 $ config = m::mock (Repository::class);
705701 $ config ->shouldReceive ('get ' )
706702 ->once ()
707703 ->with ('vat_calculator ' , [])
708704 ->andReturn ([
709705 'rules ' => [
710- ' DE ' => [
706+ $ countryCode => [
711707 'rate ' => 0.19 ,
712708 'exceptions ' => [
713709 'Heligoland ' => 0.05 ,
@@ -718,7 +714,7 @@ public function test_postal_codes_without_exceptions_overwritten_by_configuratio
718714
719715 $ vatCalculator = new VatCalculator ($ config );
720716 $ postalCode = '27498 ' ; // Heligoland
721- $ result = $ vatCalculator ->calculate ($ net , ' DE ' , $ postalCode , false );
717+ $ result = $ vatCalculator ->calculate ($ net , $ countryCode , $ postalCode , false );
722718 $ this ->assertEquals (25.20 , $ result );
723719 $ this ->assertEquals (0.05 , $ vatCalculator ->getTaxRate ());
724720 $ this ->assertEquals (1.20 , $ vatCalculator ->getTaxValue ());
@@ -736,15 +732,14 @@ public function test_should_collect_vat()
736732 public function test_should_collect_vat_from_config ()
737733 {
738734 $ countryCode = 'TEST ' ;
739- $ taxKey = 'vat_calculator.rules. ' .strtoupper ($ countryCode );
740735
741736 $ config = m::mock (Repository::class);
742737 $ config ->shouldReceive ('get ' )
743738 ->once ()
744739 ->with ('vat_calculator ' , [])
745740 ->andReturn ([
746741 'rules ' => [
747- ' TEST ' => 0.19 ,
742+ $ countryCode => 0.19 ,
748743 ],
749744 ]);
750745
@@ -811,15 +806,13 @@ public function test_calculate_net_price_with_predefined_rules_overwritten_by_co
811806 $ gross = 36.00 ;
812807 $ countryCode = 'DE ' ;
813808
814- $ taxKey = 'vat_calculator.rules. ' .strtoupper ($ countryCode );
815-
816809 $ config = m::mock (Repository::class);
817810 $ config ->shouldReceive ('get ' )
818811 ->once ()
819812 ->with ('vat_calculator ' , [])
820813 ->andReturn ([
821814 'rules ' => [
822- ' DE ' => 0.50 ,
815+ $ countryCode => 0.50 ,
823816 ],
824817 ]);
825818
@@ -984,27 +977,27 @@ public function test_calculate_low_vat_vat_with_predefined_rules_overwritten_by_
984977 $ net = 24.00 ;
985978 $ countryCode = 'DE ' ;
986979
987- $ taxKey = 'vat_calculator.rules. ' .strtoupper ($ countryCode );
988-
989980 $ config = m::mock (Repository::class);
990981 $ config ->shouldReceive ('get ' )
991982 ->once ()
992983 ->with ('vat_calculator ' , [])
993984 ->andReturn ([
994- 'DE ' => [
995- 'rate ' => 0.19 ,
996- 'rates ' => [
997- 'high ' => 0.19 ,
998- 'low ' => 0.07 ,
985+ 'rules ' => [
986+ $ countryCode => [
987+ 'rate ' => 0.19 ,
988+ 'rates ' => [
989+ 'high ' => 0.19 ,
990+ 'low ' => 0.03 ,
991+ ],
999992 ],
1000993 ],
1001994 ]);
1002995
1003996 $ vatCalculator = new VatCalculator ($ config );
1004997 $ result = $ vatCalculator ->calculate ($ net , $ countryCode , null , null , 'low ' );
1005- $ this ->assertEquals (25.68 , $ result );
1006- $ this ->assertEquals (0.07 , $ vatCalculator ->getTaxRate ());
1007- $ this ->assertEquals (1.68 , $ vatCalculator ->getTaxValue ());
998+ $ this ->assertEquals (24.72 , $ result );
999+ $ this ->assertEquals (0.03 , $ vatCalculator ->getTaxRate ());
1000+ $ this ->assertEquals (0.72 , $ vatCalculator ->getTaxValue ());
10081001 }
10091002
10101003 #[Covers('VatCalculator::isValidVatNumberFormat ' )]
0 commit comments