@@ -76,7 +76,8 @@ protected function setUp()
7676 'addQty ' ,
7777 'setCustomPrice ' ,
7878 'setOriginalCustomPrice ' ,
79- 'setData '
79+ 'setData ' ,
80+ 'setprice '
8081 ]);
8182 $ this ->quoteItemFactoryMock ->expects ($ this ->any ())
8283 ->method ('create ' )
@@ -98,7 +99,13 @@ protected function setUp()
9899
99100 $ this ->productMock = $ this ->createPartialMock (
100101 \Magento \Catalog \Model \Product::class,
101- ['getCustomOptions ' , '__wakeup ' , 'getParentProductId ' , 'getCartQty ' , 'getStickWithinParent ' ]
102+ [
103+ 'getCustomOptions ' ,
104+ '__wakeup ' ,
105+ 'getParentProductId ' ,
106+ 'getCartQty ' ,
107+ 'getStickWithinParent ' ,
108+ 'getFinalPrice ' ]
102109 );
103110 $ this ->objectMock = $ this ->createPartialMock (
104111 \Magento \Framework \DataObject::class,
@@ -239,13 +246,17 @@ public function testPrepare()
239246 $ customPrice = 400000000 ;
240247 $ itemId = 1 ;
241248 $ requestItemId = 1 ;
249+ $ finalPrice = 1000000000 ;
242250
243251 $ this ->productMock ->expects ($ this ->any ())
244252 ->method ('getCartQty ' )
245253 ->will ($ this ->returnValue ($ qty ));
246254 $ this ->productMock ->expects ($ this ->any ())
247255 ->method ('getStickWithinParent ' )
248256 ->will ($ this ->returnValue (false ));
257+ $ this ->productMock ->expects ($ this ->once ())
258+ ->method ('getFinalPrice ' )
259+ ->will ($ this ->returnValue ($ finalPrice ));
249260
250261 $ this ->itemMock ->expects ($ this ->once ())
251262 ->method ('addQty ' )
@@ -255,6 +266,9 @@ public function testPrepare()
255266 ->will ($ this ->returnValue ($ itemId ));
256267 $ this ->itemMock ->expects ($ this ->never ())
257268 ->method ('setData ' );
269+ $ this ->itemMock ->expects ($ this ->once ())
270+ ->method ('setPrice ' )
271+ ->will ($ this ->returnValue ($ this ->itemMock ));
258272
259273 $ this ->objectMock ->expects ($ this ->any ())
260274 ->method ('getCustomPrice ' )
@@ -282,13 +296,17 @@ public function testPrepareWithResetCountAndStick()
282296 $ customPrice = 400000000 ;
283297 $ itemId = 1 ;
284298 $ requestItemId = 1 ;
299+ $ finalPrice = 1000000000 ;
285300
286301 $ this ->productMock ->expects ($ this ->any ())
287302 ->method ('getCartQty ' )
288303 ->will ($ this ->returnValue ($ qty ));
289304 $ this ->productMock ->expects ($ this ->any ())
290305 ->method ('getStickWithinParent ' )
291306 ->will ($ this ->returnValue (true ));
307+ $ this ->productMock ->expects ($ this ->once ())
308+ ->method ('getFinalPrice ' )
309+ ->will ($ this ->returnValue ($ finalPrice ));
292310
293311 $ this ->itemMock ->expects ($ this ->once ())
294312 ->method ('addQty ' )
@@ -298,6 +316,9 @@ public function testPrepareWithResetCountAndStick()
298316 ->will ($ this ->returnValue ($ itemId ));
299317 $ this ->itemMock ->expects ($ this ->never ())
300318 ->method ('setData ' );
319+ $ this ->itemMock ->expects ($ this ->once ())
320+ ->method ('setPrice ' )
321+ ->will ($ this ->returnValue ($ this ->itemMock ));
301322
302323 $ this ->objectMock ->expects ($ this ->any ())
303324 ->method ('getCustomPrice ' )
@@ -325,13 +346,17 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
325346 $ customPrice = 400000000 ;
326347 $ itemId = 1 ;
327348 $ requestItemId = 2 ;
349+ $ finalPrice = 1000000000 ;
328350
329351 $ this ->productMock ->expects ($ this ->any ())
330352 ->method ('getCartQty ' )
331353 ->will ($ this ->returnValue ($ qty ));
332354 $ this ->productMock ->expects ($ this ->any ())
333355 ->method ('getStickWithinParent ' )
334356 ->will ($ this ->returnValue (false ));
357+ $ this ->productMock ->expects ($ this ->once ())
358+ ->method ('getFinalPrice ' )
359+ ->will ($ this ->returnValue ($ finalPrice ));
335360
336361 $ this ->itemMock ->expects ($ this ->once ())
337362 ->method ('addQty ' )
@@ -341,6 +366,9 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
341366 ->will ($ this ->returnValue ($ itemId ));
342367 $ this ->itemMock ->expects ($ this ->never ())
343368 ->method ('setData ' );
369+ $ this ->itemMock ->expects ($ this ->once ())
370+ ->method ('setPrice ' )
371+ ->will ($ this ->returnValue ($ this ->itemMock ));
344372
345373 $ this ->objectMock ->expects ($ this ->any ())
346374 ->method ('getCustomPrice ' )
@@ -368,6 +396,7 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
368396 $ customPrice = 400000000 ;
369397 $ itemId = 1 ;
370398 $ requestItemId = 1 ;
399+ $ finalPrice = 1000000000 ;
371400
372401 $ this ->objectMock ->expects ($ this ->any ())
373402 ->method ('getResetCount ' )
@@ -386,10 +415,16 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
386415 $ this ->productMock ->expects ($ this ->any ())
387416 ->method ('getStickWithinParent ' )
388417 ->will ($ this ->returnValue (false ));
418+ $ this ->productMock ->expects ($ this ->once ())
419+ ->method ('getFinalPrice ' )
420+ ->will ($ this ->returnValue ($ finalPrice ));
389421
390422 $ this ->itemMock ->expects ($ this ->once ())
391423 ->method ('addQty ' )
392424 ->with ($ qty );
425+ $ this ->itemMock ->expects ($ this ->once ())
426+ ->method ('setPrice ' )
427+ ->will ($ this ->returnValue ($ this ->itemMock ));
393428
394429 $ this ->objectMock ->expects ($ this ->any ())
395430 ->method ('getCustomPrice ' )
0 commit comments