@@ -236,8 +236,15 @@ protected function getPreparedItem(): AbstractItem
236
236
* @var AbstractItem|MockObject $item
237
237
*/
238
238
$ item = $ this ->getMockBuilder (Item::class)
239
- ->addMethods (['setDiscountAmount ' , 'setBaseDiscountAmount ' , 'setDiscountPercent ' , 'setAppliedRuleIds ' ])
240
- ->onlyMethods (['getAddress ' , 'getChildren ' , 'getExtensionAttributes ' , 'getProduct ' ])
239
+ ->addMethods (
240
+ [
241
+ 'setDiscountAmount ' ,
242
+ 'setBaseDiscountAmount ' ,
243
+ 'setDiscountPercent ' ,
244
+ 'setAppliedRuleIds ' ,
245
+ 'getAppliedRuleIds '
246
+ ]
247
+ )->onlyMethods (['getAddress ' , 'getChildren ' , 'getExtensionAttributes ' , 'getProduct ' , 'getQuote ' ])
241
248
->disableOriginalConstructor ()
242
249
->getMock ();
243
250
$ itemExtension = $ this ->getMockBuilder (ExtensionAttributesInterface::class)
@@ -253,6 +260,9 @@ protected function getPreparedItem(): AbstractItem
253
260
$ address ->expects ($ this ->any ())
254
261
->method ('getQuote ' )
255
262
->willReturn ($ quote );
263
+ $ item ->expects ($ this ->any ())
264
+ ->method ('getQuote ' )
265
+ ->willReturn ($ quote );
256
266
257
267
return $ item ;
258
268
}
@@ -290,4 +300,19 @@ protected function applyRule(MockObject $item, MockObject $rule): void
290
300
->with ($ this ->anything ())
291
301
->willReturn ($ discountCalc );
292
302
}
303
+
304
+ public function testSetAppliedRuleIds ()
305
+ {
306
+ $ item = $ this ->getPreparedItem ();
307
+ $ ruleId = 1 ;
308
+ $ appliedRuleIds = [$ ruleId => $ ruleId ];
309
+
310
+ $ item ->expects ($ this ->once ())
311
+ ->method ('setAppliedRuleIds ' )
312
+ ->with ($ ruleId );
313
+ $ item ->expects ($ this ->never ())
314
+ ->method ('getAppliedRuleIds ' );
315
+
316
+ $ this ->rulesApplier ->setAppliedRuleIds ($ item , $ appliedRuleIds );
317
+ }
293
318
}
0 commit comments