@@ -130,7 +130,9 @@ function ($argument) {
130130
131131 $ this ->addressMock = $ this ->getMockBuilder (Address::class)
132132 ->addMethods (['getShippingAmount ' ])
133- ->onlyMethods (['getQuote ' , 'getAllItems ' , 'getExtensionAttributes ' , 'getCustomAttributesCodes ' ])
133+ ->onlyMethods (
134+ ['getQuote ' , 'getAllItems ' , 'getExtensionAttributes ' , 'getCustomAttributesCodes ' , 'setBaseDiscountAmount ' ]
135+ )
134136 ->disableOriginalConstructor ()
135137 ->getMock ();
136138 $ addressExtension = $ this ->getMockBuilder (
@@ -178,7 +180,7 @@ public function testCollectItemNoDiscount()
178180 {
179181 $ itemNoDiscount = $ this ->getMockBuilder (Item::class)
180182 ->addMethods (['getNoDiscount ' ])
181- ->onlyMethods (['getExtensionAttributes ' , 'getParentItem ' , 'getId ' ])
183+ ->onlyMethods (['getExtensionAttributes ' , 'getParentItem ' , 'getId ' , ' getAddress ' ])
182184 ->disableOriginalConstructor ()
183185 ->getMock ();
184186 $ itemExtension = $ this ->getMockBuilder (
@@ -191,6 +193,7 @@ public function testCollectItemNoDiscount()
191193 $ itemNoDiscount ->expects ($ this ->any ())->method ('getExtensionAttributes ' )->willReturn ($ itemExtension );
192194 $ itemNoDiscount ->expects ($ this ->any ())->method ('getId ' )->willReturn (1 );
193195 $ itemNoDiscount ->expects ($ this ->once ())->method ('getNoDiscount ' )->willReturn (true );
196+ $ itemNoDiscount ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->addressMock );
194197 $ this ->validatorMock ->expects ($ this ->once ())->method ('sortItemsByPriority ' )
195198 ->with ([$ itemNoDiscount ], $ this ->addressMock )
196199 ->willReturnArgument (0 );
@@ -213,6 +216,7 @@ public function testCollectItemNoDiscount()
213216 $ this ->addressMock ->expects ($ this ->any ())->method ('getQuote ' )->willReturn ($ quoteMock );
214217 $ this ->shippingAssignmentMock ->expects ($ this ->any ())->method ('getItems ' )->willReturn ([$ itemNoDiscount ]);
215218 $ this ->addressMock ->expects ($ this ->any ())->method ('getShippingAmount ' )->willReturn (true );
219+ $ this ->addressMock ->expects ($ this ->atLeastOnce ())->method ('setBaseDiscountAmount ' )->with (0 )->willReturnSelf ();
216220
217221 $ totalMock = $ this ->getMockBuilder (Total::class)
218222 ->addMethods (
@@ -234,13 +238,14 @@ public function testCollectItemHasParent()
234238 {
235239 $ itemWithParentId = $ this ->getMockBuilder (Item::class)
236240 ->addMethods (['getNoDiscount ' ])
237- ->onlyMethods (['getParentItem ' , 'getId ' , 'getExtensionAttributes ' ])
241+ ->onlyMethods (['getParentItem ' , 'getId ' , 'getExtensionAttributes ' , ' getAddress ' ])
238242 ->disableOriginalConstructor ()
239243 ->getMock ();
240244 $ itemWithParentId ->expects ($ this ->once ())->method ('getNoDiscount ' )->willReturn (false );
241245 $ itemWithParentId ->expects ($ this ->any ())->method ('getId ' )->willReturn (1 );
242246 $ itemWithParentId ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (true );
243247 $ itemWithParentId ->expects ($ this ->any ())->method ('getExtensionAttributes ' )->willReturn (false );
248+ $ itemWithParentId ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->addressMock );
244249
245250 $ this ->validatorMock ->expects ($ this ->any ())->method ('canApplyDiscount ' )->willReturn (true );
246251 $ this ->validatorMock ->expects ($ this ->any ())->method ('sortItemsByPriority ' )
@@ -267,6 +272,7 @@ public function testCollectItemHasParent()
267272
268273 $ this ->addressMock ->expects ($ this ->any ())->method ('getQuote ' )->willReturn ($ quoteMock );
269274 $ this ->addressMock ->expects ($ this ->any ())->method ('getShippingAmount ' )->willReturn (true );
275+ $ this ->addressMock ->expects ($ this ->atLeastOnce ())->method ('setBaseDiscountAmount ' )->with (0 )->willReturnSelf ();
270276 $ this ->shippingAssignmentMock ->expects ($ this ->any ())->method ('getItems ' )->willReturn ([$ itemWithParentId ]);
271277 $ totalMock = $ this ->getMockBuilder (Total::class)
272278 ->addMethods (
@@ -295,6 +301,7 @@ public function testCollectItemHasNoChildren()
295301 'getChildren ' ,
296302 'getExtensionAttributes ' ,
297303 'getId ' ,
304+ 'getAddress ' ,
298305 ]
299306 )->addMethods (
300307 [
@@ -318,6 +325,7 @@ public function testCollectItemHasNoChildren()
318325 $ itemWithChildren ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (false );
319326 $ itemWithChildren ->expects ($ this ->once ())->method ('getHasChildren ' )->willReturn (false );
320327 $ itemWithChildren ->expects ($ this ->any ())->method ('getId ' )->willReturn (2 );
328+ $ itemWithChildren ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->addressMock );
321329
322330 $ this ->validatorMock ->expects ($ this ->any ())->method ('canApplyDiscount ' )->willReturn (true );
323331 $ this ->validatorMock ->expects ($ this ->once ())->method ('sortItemsByPriority ' )
@@ -343,6 +351,7 @@ public function testCollectItemHasNoChildren()
343351 $ this ->addressMock ->expects ($ this ->any ())->method ('getAllItems ' )->willReturn ([$ itemWithChildren ]);
344352 $ this ->addressMock ->expects ($ this ->any ())->method ('getQuote ' )->willReturn ($ quoteMock );
345353 $ this ->addressMock ->expects ($ this ->any ())->method ('getShippingAmount ' )->willReturn (true );
354+ $ this ->addressMock ->expects ($ this ->atLeastOnce ())->method ('setBaseDiscountAmount ' )->with (0 )->willReturnSelf ();
346355 $ this ->shippingAssignmentMock ->expects ($ this ->any ())->method ('getItems ' )->willReturn ([$ itemWithChildren ]);
347356
348357 $ totalMock = $ this ->getMockBuilder (Total::class)
0 commit comments