@@ -192,7 +192,7 @@ public function collectDataProvider()
192
192
'base_shipping_amount ' => 30 ,
193
193
'tax_amount ' => 0.82 ,
194
194
'base_tax_amount ' => 0.82 ,
195
- 'invoice ' => new MagentoObject (
195
+ 'invoice ' => $ this -> createInvoiceMock (
196
196
[
197
197
'tax_amount ' => 24.33 ,
198
198
'base_tax_amount ' => 24.33 ,
@@ -283,7 +283,7 @@ public function collectDataProvider()
283
283
'base_shipping_amount ' => 30 ,
284
284
'tax_amount ' => 0.82 * $ currencyRatio ,
285
285
'base_tax_amount ' => 0.82 ,
286
- 'invoice ' => new MagentoObject (
286
+ 'invoice ' => $ this -> createInvoiceMock (
287
287
[
288
288
'tax_amount ' => 24.33 * $ currencyRatio ,
289
289
'base_tax_amount ' => 24.33 ,
@@ -360,7 +360,7 @@ public function collectDataProvider()
360
360
'base_shipping_amount ' => 30 ,
361
361
'tax_amount ' => 1.65 ,
362
362
'base_tax_amount ' => 1.65 ,
363
- 'invoice ' => new MagentoObject (
363
+ 'invoice ' => $ this -> createInvoiceMock (
364
364
[
365
365
'tax_amount ' => 11.14 ,
366
366
'base_tax_amount ' => 11.14 ,
@@ -438,7 +438,7 @@ public function collectDataProvider()
438
438
'base_shipping_amount ' => 0 ,
439
439
'tax_amount ' => 0.82 ,
440
440
'base_tax_amount ' => 0.82 ,
441
- 'invoice ' => new MagentoObject (
441
+ 'invoice ' => $ this -> createInvoiceMock (
442
442
[
443
443
'tax_amount ' => 16.09 ,
444
444
'base_tax_amount ' => 16.09 ,
@@ -587,7 +587,7 @@ public function collectDataProvider()
587
587
'base_grand_total ' => 60.82 ,
588
588
'tax_amount ' => 0.82 ,
589
589
'base_tax_amount ' => 0.82 ,
590
- 'invoice ' => new MagentoObject (
590
+ 'invoice ' => $ this -> createInvoiceMock (
591
591
[
592
592
'tax_amount ' => 16.09 ,
593
593
'base_tax_amount ' => 16.09 ,
@@ -779,4 +779,40 @@ protected function getCreditmemoItem($creditmemoItemData)
779
779
$ creditmemoItem ->setData ('qty ' , $ creditmemoItemData ['qty ' ]);
780
780
return $ creditmemoItem ;
781
781
}
782
+
783
+ /**
784
+ * Create invoice mock object
785
+ *
786
+ * @param array $data
787
+ * @return MockObject|Invoice
788
+ */
789
+ private function createInvoiceMock (array $ data ): MockObject
790
+ {
791
+ /** @var MockObject|Invoice $invoice */
792
+ $ invoice = $ this ->getMockBuilder (Invoice::class)
793
+ ->disableOriginalConstructor ()
794
+ ->disableOriginalClone ()
795
+ ->disableArgumentCloning ()
796
+ ->disallowMockingUnknownTypes ()
797
+ ->addMethods (['getBaseShippingDiscountTaxCompensationAmount ' ])
798
+ ->onlyMethods ([
799
+ 'getTaxAmount ' ,
800
+ 'getBaseTaxAmount ' ,
801
+ 'getShippingTaxAmount ' ,
802
+ 'getBaseShippingTaxAmount ' ,
803
+ 'getShippingDiscountTaxCompensationAmount '
804
+ ])
805
+ ->getMock ();
806
+
807
+ $ invoice ->method ('getTaxAmount ' )->willReturn ($ data ['tax_amount ' ] ?? 0 );
808
+ $ invoice ->method ('getBaseTaxAmount ' )->willReturn ($ data ['base_tax_amount ' ] ?? 0 );
809
+ $ invoice ->method ('getShippingTaxAmount ' )->willReturn ($ data ['shipping_tax_amount ' ] ?? 0 );
810
+ $ invoice ->method ('getBaseShippingTaxAmount ' )->willReturn ($ data ['base_shipping_tax_amount ' ] ?? 0 );
811
+ $ invoice ->method ('getShippingDiscountTaxCompensationAmount ' )
812
+ ->willReturn ($ data ['shipping_discount_tax_compensation_amount ' ] ?? 0 );
813
+ $ invoice ->method ('getBaseShippingDiscountTaxCompensationAmount ' )
814
+ ->willReturn ($ data ['base_shipping_discount_tax_compensation_amount ' ] ?? 0 );
815
+
816
+ return $ invoice ;
817
+ }
782
818
}
0 commit comments