@@ -130,7 +130,9 @@ function ($argument) {
130
130
131
131
$ this ->addressMock = $ this ->getMockBuilder (Address::class)
132
132
->addMethods (['getShippingAmount ' ])
133
- ->onlyMethods (['getQuote ' , 'getAllItems ' , 'getExtensionAttributes ' , 'getCustomAttributesCodes ' ])
133
+ ->onlyMethods (
134
+ ['getQuote ' , 'getAllItems ' , 'getExtensionAttributes ' , 'getCustomAttributesCodes ' , 'setBaseDiscountAmount ' ]
135
+ )
134
136
->disableOriginalConstructor ()
135
137
->getMock ();
136
138
$ addressExtension = $ this ->getMockBuilder (
@@ -178,7 +180,7 @@ public function testCollectItemNoDiscount()
178
180
{
179
181
$ itemNoDiscount = $ this ->getMockBuilder (Item::class)
180
182
->addMethods (['getNoDiscount ' ])
181
- ->onlyMethods (['getExtensionAttributes ' , 'getParentItem ' , 'getId ' ])
183
+ ->onlyMethods (['getExtensionAttributes ' , 'getParentItem ' , 'getId ' , ' getAddress ' ])
182
184
->disableOriginalConstructor ()
183
185
->getMock ();
184
186
$ itemExtension = $ this ->getMockBuilder (
@@ -191,6 +193,7 @@ public function testCollectItemNoDiscount()
191
193
$ itemNoDiscount ->expects ($ this ->any ())->method ('getExtensionAttributes ' )->willReturn ($ itemExtension );
192
194
$ itemNoDiscount ->expects ($ this ->any ())->method ('getId ' )->willReturn (1 );
193
195
$ itemNoDiscount ->expects ($ this ->once ())->method ('getNoDiscount ' )->willReturn (true );
196
+ $ itemNoDiscount ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->addressMock );
194
197
$ this ->validatorMock ->expects ($ this ->once ())->method ('sortItemsByPriority ' )
195
198
->with ([$ itemNoDiscount ], $ this ->addressMock )
196
199
->willReturnArgument (0 );
@@ -213,6 +216,7 @@ public function testCollectItemNoDiscount()
213
216
$ this ->addressMock ->expects ($ this ->any ())->method ('getQuote ' )->willReturn ($ quoteMock );
214
217
$ this ->shippingAssignmentMock ->expects ($ this ->any ())->method ('getItems ' )->willReturn ([$ itemNoDiscount ]);
215
218
$ this ->addressMock ->expects ($ this ->any ())->method ('getShippingAmount ' )->willReturn (true );
219
+ $ this ->addressMock ->expects ($ this ->atLeastOnce ())->method ('setBaseDiscountAmount ' )->with (0 )->willReturnSelf ();
216
220
217
221
$ totalMock = $ this ->getMockBuilder (Total::class)
218
222
->addMethods (
@@ -234,13 +238,14 @@ public function testCollectItemHasParent()
234
238
{
235
239
$ itemWithParentId = $ this ->getMockBuilder (Item::class)
236
240
->addMethods (['getNoDiscount ' ])
237
- ->onlyMethods (['getParentItem ' , 'getId ' , 'getExtensionAttributes ' ])
241
+ ->onlyMethods (['getParentItem ' , 'getId ' , 'getExtensionAttributes ' , ' getAddress ' ])
238
242
->disableOriginalConstructor ()
239
243
->getMock ();
240
244
$ itemWithParentId ->expects ($ this ->once ())->method ('getNoDiscount ' )->willReturn (false );
241
245
$ itemWithParentId ->expects ($ this ->any ())->method ('getId ' )->willReturn (1 );
242
246
$ itemWithParentId ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (true );
243
247
$ itemWithParentId ->expects ($ this ->any ())->method ('getExtensionAttributes ' )->willReturn (false );
248
+ $ itemWithParentId ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->addressMock );
244
249
245
250
$ this ->validatorMock ->expects ($ this ->any ())->method ('canApplyDiscount ' )->willReturn (true );
246
251
$ this ->validatorMock ->expects ($ this ->any ())->method ('sortItemsByPriority ' )
@@ -267,6 +272,7 @@ public function testCollectItemHasParent()
267
272
268
273
$ this ->addressMock ->expects ($ this ->any ())->method ('getQuote ' )->willReturn ($ quoteMock );
269
274
$ this ->addressMock ->expects ($ this ->any ())->method ('getShippingAmount ' )->willReturn (true );
275
+ $ this ->addressMock ->expects ($ this ->atLeastOnce ())->method ('setBaseDiscountAmount ' )->with (0 )->willReturnSelf ();
270
276
$ this ->shippingAssignmentMock ->expects ($ this ->any ())->method ('getItems ' )->willReturn ([$ itemWithParentId ]);
271
277
$ totalMock = $ this ->getMockBuilder (Total::class)
272
278
->addMethods (
@@ -295,6 +301,7 @@ public function testCollectItemHasNoChildren()
295
301
'getChildren ' ,
296
302
'getExtensionAttributes ' ,
297
303
'getId ' ,
304
+ 'getAddress ' ,
298
305
]
299
306
)->addMethods (
300
307
[
@@ -318,6 +325,7 @@ public function testCollectItemHasNoChildren()
318
325
$ itemWithChildren ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (false );
319
326
$ itemWithChildren ->expects ($ this ->once ())->method ('getHasChildren ' )->willReturn (false );
320
327
$ itemWithChildren ->expects ($ this ->any ())->method ('getId ' )->willReturn (2 );
328
+ $ itemWithChildren ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->addressMock );
321
329
322
330
$ this ->validatorMock ->expects ($ this ->any ())->method ('canApplyDiscount ' )->willReturn (true );
323
331
$ this ->validatorMock ->expects ($ this ->once ())->method ('sortItemsByPriority ' )
@@ -343,6 +351,7 @@ public function testCollectItemHasNoChildren()
343
351
$ this ->addressMock ->expects ($ this ->any ())->method ('getAllItems ' )->willReturn ([$ itemWithChildren ]);
344
352
$ this ->addressMock ->expects ($ this ->any ())->method ('getQuote ' )->willReturn ($ quoteMock );
345
353
$ this ->addressMock ->expects ($ this ->any ())->method ('getShippingAmount ' )->willReturn (true );
354
+ $ this ->addressMock ->expects ($ this ->atLeastOnce ())->method ('setBaseDiscountAmount ' )->with (0 )->willReturnSelf ();
346
355
$ this ->shippingAssignmentMock ->expects ($ this ->any ())->method ('getItems ' )->willReturn ([$ itemWithChildren ]);
347
356
348
357
$ totalMock = $ this ->getMockBuilder (Total::class)
0 commit comments