33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+ declare (strict_types=1 );
7+
68namespace Magento \Quote \Test \Unit \Model \Quote \Item ;
79
810use Magento \Catalog \Model \Product ;
@@ -68,16 +70,20 @@ protected function setUp()
6870 ['create ' ]
6971 );
7072
71- $ this ->itemMock = $ this ->createPartialMock (\Magento \Quote \Model \Quote \Item::class, [
73+ $ this ->itemMock = $ this ->createPartialMock (
74+ \Magento \Quote \Model \Quote \Item::class,
75+ [
7276 'getId ' ,
7377 'setOptions ' ,
7478 '__wakeup ' ,
7579 'setProduct ' ,
7680 'addQty ' ,
7781 'setCustomPrice ' ,
7882 'setOriginalCustomPrice ' ,
79- 'setData '
80- ]);
83+ 'setData ' ,
84+ 'setprice '
85+ ]
86+ );
8187 $ this ->quoteItemFactoryMock ->expects ($ this ->any ())
8288 ->method ('create ' )
8389 ->will ($ this ->returnValue ($ this ->itemMock ));
@@ -98,7 +104,13 @@ protected function setUp()
98104
99105 $ this ->productMock = $ this ->createPartialMock (
100106 \Magento \Catalog \Model \Product::class,
101- ['getCustomOptions ' , '__wakeup ' , 'getParentProductId ' , 'getCartQty ' , 'getStickWithinParent ' ]
107+ [
108+ 'getCustomOptions ' ,
109+ '__wakeup ' ,
110+ 'getParentProductId ' ,
111+ 'getCartQty ' ,
112+ 'getStickWithinParent ' ,
113+ 'getFinalPrice ' ]
102114 );
103115 $ this ->objectMock = $ this ->createPartialMock (
104116 \Magento \Framework \DataObject::class,
@@ -239,13 +251,17 @@ public function testPrepare()
239251 $ customPrice = 400000000 ;
240252 $ itemId = 1 ;
241253 $ requestItemId = 1 ;
254+ $ finalPrice = 1000000000 ;
242255
243256 $ this ->productMock ->expects ($ this ->any ())
244257 ->method ('getCartQty ' )
245258 ->will ($ this ->returnValue ($ qty ));
246259 $ this ->productMock ->expects ($ this ->any ())
247260 ->method ('getStickWithinParent ' )
248261 ->will ($ this ->returnValue (false ));
262+ $ this ->productMock ->expects ($ this ->once ())
263+ ->method ('getFinalPrice ' )
264+ ->will ($ this ->returnValue ($ finalPrice ));
249265
250266 $ this ->itemMock ->expects ($ this ->once ())
251267 ->method ('addQty ' )
@@ -255,6 +271,9 @@ public function testPrepare()
255271 ->will ($ this ->returnValue ($ itemId ));
256272 $ this ->itemMock ->expects ($ this ->never ())
257273 ->method ('setData ' );
274+ $ this ->itemMock ->expects ($ this ->once ())
275+ ->method ('setPrice ' )
276+ ->will ($ this ->returnValue ($ this ->itemMock ));
258277
259278 $ this ->objectMock ->expects ($ this ->any ())
260279 ->method ('getCustomPrice ' )
@@ -282,13 +301,17 @@ public function testPrepareWithResetCountAndStick()
282301 $ customPrice = 400000000 ;
283302 $ itemId = 1 ;
284303 $ requestItemId = 1 ;
304+ $ finalPrice = 1000000000 ;
285305
286306 $ this ->productMock ->expects ($ this ->any ())
287307 ->method ('getCartQty ' )
288308 ->will ($ this ->returnValue ($ qty ));
289309 $ this ->productMock ->expects ($ this ->any ())
290310 ->method ('getStickWithinParent ' )
291311 ->will ($ this ->returnValue (true ));
312+ $ this ->productMock ->expects ($ this ->once ())
313+ ->method ('getFinalPrice ' )
314+ ->will ($ this ->returnValue ($ finalPrice ));
292315
293316 $ this ->itemMock ->expects ($ this ->once ())
294317 ->method ('addQty ' )
@@ -298,6 +321,9 @@ public function testPrepareWithResetCountAndStick()
298321 ->will ($ this ->returnValue ($ itemId ));
299322 $ this ->itemMock ->expects ($ this ->never ())
300323 ->method ('setData ' );
324+ $ this ->itemMock ->expects ($ this ->once ())
325+ ->method ('setPrice ' )
326+ ->will ($ this ->returnValue ($ this ->itemMock ));
301327
302328 $ this ->objectMock ->expects ($ this ->any ())
303329 ->method ('getCustomPrice ' )
@@ -325,13 +351,17 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
325351 $ customPrice = 400000000 ;
326352 $ itemId = 1 ;
327353 $ requestItemId = 2 ;
354+ $ finalPrice = 1000000000 ;
328355
329356 $ this ->productMock ->expects ($ this ->any ())
330357 ->method ('getCartQty ' )
331358 ->will ($ this ->returnValue ($ qty ));
332359 $ this ->productMock ->expects ($ this ->any ())
333360 ->method ('getStickWithinParent ' )
334361 ->will ($ this ->returnValue (false ));
362+ $ this ->productMock ->expects ($ this ->once ())
363+ ->method ('getFinalPrice ' )
364+ ->will ($ this ->returnValue ($ finalPrice ));
335365
336366 $ this ->itemMock ->expects ($ this ->once ())
337367 ->method ('addQty ' )
@@ -341,6 +371,9 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
341371 ->will ($ this ->returnValue ($ itemId ));
342372 $ this ->itemMock ->expects ($ this ->never ())
343373 ->method ('setData ' );
374+ $ this ->itemMock ->expects ($ this ->once ())
375+ ->method ('setPrice ' )
376+ ->will ($ this ->returnValue ($ this ->itemMock ));
344377
345378 $ this ->objectMock ->expects ($ this ->any ())
346379 ->method ('getCustomPrice ' )
@@ -368,6 +401,7 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
368401 $ customPrice = 400000000 ;
369402 $ itemId = 1 ;
370403 $ requestItemId = 1 ;
404+ $ finalPrice = 1000000000 ;
371405
372406 $ this ->objectMock ->expects ($ this ->any ())
373407 ->method ('getResetCount ' )
@@ -386,10 +420,16 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
386420 $ this ->productMock ->expects ($ this ->any ())
387421 ->method ('getStickWithinParent ' )
388422 ->will ($ this ->returnValue (false ));
423+ $ this ->productMock ->expects ($ this ->once ())
424+ ->method ('getFinalPrice ' )
425+ ->will ($ this ->returnValue ($ finalPrice ));
389426
390427 $ this ->itemMock ->expects ($ this ->once ())
391428 ->method ('addQty ' )
392429 ->with ($ qty );
430+ $ this ->itemMock ->expects ($ this ->once ())
431+ ->method ('setPrice ' )
432+ ->will ($ this ->returnValue ($ this ->itemMock ));
393433
394434 $ this ->objectMock ->expects ($ this ->any ())
395435 ->method ('getCustomPrice ' )
0 commit comments