@@ -192,7 +192,7 @@ public function collectDataProvider()
192192 'base_shipping_amount ' => 30 ,
193193 'tax_amount ' => 0.82 ,
194194 'base_tax_amount ' => 0.82 ,
195- 'invoice ' => new MagentoObject (
195+ 'invoice ' => $ this -> createInvoiceMock (
196196 [
197197 'tax_amount ' => 24.33 ,
198198 'base_tax_amount ' => 24.33 ,
@@ -283,7 +283,7 @@ public function collectDataProvider()
283283 'base_shipping_amount ' => 30 ,
284284 'tax_amount ' => 0.82 * $ currencyRatio ,
285285 'base_tax_amount ' => 0.82 ,
286- 'invoice ' => new MagentoObject (
286+ 'invoice ' => $ this -> createInvoiceMock (
287287 [
288288 'tax_amount ' => 24.33 * $ currencyRatio ,
289289 'base_tax_amount ' => 24.33 ,
@@ -360,7 +360,7 @@ public function collectDataProvider()
360360 'base_shipping_amount ' => 30 ,
361361 'tax_amount ' => 1.65 ,
362362 'base_tax_amount ' => 1.65 ,
363- 'invoice ' => new MagentoObject (
363+ 'invoice ' => $ this -> createInvoiceMock (
364364 [
365365 'tax_amount ' => 11.14 ,
366366 'base_tax_amount ' => 11.14 ,
@@ -438,7 +438,7 @@ public function collectDataProvider()
438438 'base_shipping_amount ' => 0 ,
439439 'tax_amount ' => 0.82 ,
440440 'base_tax_amount ' => 0.82 ,
441- 'invoice ' => new MagentoObject (
441+ 'invoice ' => $ this -> createInvoiceMock (
442442 [
443443 'tax_amount ' => 16.09 ,
444444 'base_tax_amount ' => 16.09 ,
@@ -587,7 +587,7 @@ public function collectDataProvider()
587587 'base_grand_total ' => 60.82 ,
588588 'tax_amount ' => 0.82 ,
589589 'base_tax_amount ' => 0.82 ,
590- 'invoice ' => new MagentoObject (
590+ 'invoice ' => $ this -> createInvoiceMock (
591591 [
592592 'tax_amount ' => 16.09 ,
593593 'base_tax_amount ' => 16.09 ,
@@ -779,4 +779,40 @@ protected function getCreditmemoItem($creditmemoItemData)
779779 $ creditmemoItem ->setData ('qty ' , $ creditmemoItemData ['qty ' ]);
780780 return $ creditmemoItem ;
781781 }
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+ }
782818}
0 commit comments