@@ -236,8 +236,15 @@ protected function getPreparedItem(): AbstractItem
236236 * @var AbstractItem|MockObject $item
237237 */
238238 $ 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 ' ])
241248 ->disableOriginalConstructor ()
242249 ->getMock ();
243250 $ itemExtension = $ this ->getMockBuilder (ExtensionAttributesInterface::class)
@@ -253,6 +260,9 @@ protected function getPreparedItem(): AbstractItem
253260 $ address ->expects ($ this ->any ())
254261 ->method ('getQuote ' )
255262 ->willReturn ($ quote );
263+ $ item ->expects ($ this ->any ())
264+ ->method ('getQuote ' )
265+ ->willReturn ($ quote );
256266
257267 return $ item ;
258268 }
@@ -290,4 +300,19 @@ protected function applyRule(MockObject $item, MockObject $rule): void
290300 ->with ($ this ->anything ())
291301 ->willReturn ($ discountCalc );
292302 }
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+ }
293318}
0 commit comments