3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Quote \Test \Unit \Model \Quote \Item ;
7
9
8
10
use Magento \Catalog \Model \Product ;
@@ -68,16 +70,20 @@ protected function setUp()
68
70
['create ' ]
69
71
);
70
72
71
- $ this ->itemMock = $ this ->createPartialMock (\Magento \Quote \Model \Quote \Item::class, [
73
+ $ this ->itemMock = $ this ->createPartialMock (
74
+ \Magento \Quote \Model \Quote \Item::class,
75
+ [
72
76
'getId ' ,
73
77
'setOptions ' ,
74
78
'__wakeup ' ,
75
79
'setProduct ' ,
76
80
'addQty ' ,
77
81
'setCustomPrice ' ,
78
82
'setOriginalCustomPrice ' ,
79
- 'setData '
80
- ]);
83
+ 'setData ' ,
84
+ 'setprice '
85
+ ]
86
+ );
81
87
$ this ->quoteItemFactoryMock ->expects ($ this ->any ())
82
88
->method ('create ' )
83
89
->will ($ this ->returnValue ($ this ->itemMock ));
@@ -98,7 +104,13 @@ protected function setUp()
98
104
99
105
$ this ->productMock = $ this ->createPartialMock (
100
106
\Magento \Catalog \Model \Product::class,
101
- ['getCustomOptions ' , '__wakeup ' , 'getParentProductId ' , 'getCartQty ' , 'getStickWithinParent ' ]
107
+ [
108
+ 'getCustomOptions ' ,
109
+ '__wakeup ' ,
110
+ 'getParentProductId ' ,
111
+ 'getCartQty ' ,
112
+ 'getStickWithinParent ' ,
113
+ 'getFinalPrice ' ]
102
114
);
103
115
$ this ->objectMock = $ this ->createPartialMock (
104
116
\Magento \Framework \DataObject::class,
@@ -239,13 +251,17 @@ public function testPrepare()
239
251
$ customPrice = 400000000 ;
240
252
$ itemId = 1 ;
241
253
$ requestItemId = 1 ;
254
+ $ finalPrice = 1000000000 ;
242
255
243
256
$ this ->productMock ->expects ($ this ->any ())
244
257
->method ('getCartQty ' )
245
258
->will ($ this ->returnValue ($ qty ));
246
259
$ this ->productMock ->expects ($ this ->any ())
247
260
->method ('getStickWithinParent ' )
248
261
->will ($ this ->returnValue (false ));
262
+ $ this ->productMock ->expects ($ this ->once ())
263
+ ->method ('getFinalPrice ' )
264
+ ->will ($ this ->returnValue ($ finalPrice ));
249
265
250
266
$ this ->itemMock ->expects ($ this ->once ())
251
267
->method ('addQty ' )
@@ -255,6 +271,9 @@ public function testPrepare()
255
271
->will ($ this ->returnValue ($ itemId ));
256
272
$ this ->itemMock ->expects ($ this ->never ())
257
273
->method ('setData ' );
274
+ $ this ->itemMock ->expects ($ this ->once ())
275
+ ->method ('setPrice ' )
276
+ ->will ($ this ->returnValue ($ this ->itemMock ));
258
277
259
278
$ this ->objectMock ->expects ($ this ->any ())
260
279
->method ('getCustomPrice ' )
@@ -282,13 +301,17 @@ public function testPrepareWithResetCountAndStick()
282
301
$ customPrice = 400000000 ;
283
302
$ itemId = 1 ;
284
303
$ requestItemId = 1 ;
304
+ $ finalPrice = 1000000000 ;
285
305
286
306
$ this ->productMock ->expects ($ this ->any ())
287
307
->method ('getCartQty ' )
288
308
->will ($ this ->returnValue ($ qty ));
289
309
$ this ->productMock ->expects ($ this ->any ())
290
310
->method ('getStickWithinParent ' )
291
311
->will ($ this ->returnValue (true ));
312
+ $ this ->productMock ->expects ($ this ->once ())
313
+ ->method ('getFinalPrice ' )
314
+ ->will ($ this ->returnValue ($ finalPrice ));
292
315
293
316
$ this ->itemMock ->expects ($ this ->once ())
294
317
->method ('addQty ' )
@@ -298,6 +321,9 @@ public function testPrepareWithResetCountAndStick()
298
321
->will ($ this ->returnValue ($ itemId ));
299
322
$ this ->itemMock ->expects ($ this ->never ())
300
323
->method ('setData ' );
324
+ $ this ->itemMock ->expects ($ this ->once ())
325
+ ->method ('setPrice ' )
326
+ ->will ($ this ->returnValue ($ this ->itemMock ));
301
327
302
328
$ this ->objectMock ->expects ($ this ->any ())
303
329
->method ('getCustomPrice ' )
@@ -325,13 +351,17 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
325
351
$ customPrice = 400000000 ;
326
352
$ itemId = 1 ;
327
353
$ requestItemId = 2 ;
354
+ $ finalPrice = 1000000000 ;
328
355
329
356
$ this ->productMock ->expects ($ this ->any ())
330
357
->method ('getCartQty ' )
331
358
->will ($ this ->returnValue ($ qty ));
332
359
$ this ->productMock ->expects ($ this ->any ())
333
360
->method ('getStickWithinParent ' )
334
361
->will ($ this ->returnValue (false ));
362
+ $ this ->productMock ->expects ($ this ->once ())
363
+ ->method ('getFinalPrice ' )
364
+ ->will ($ this ->returnValue ($ finalPrice ));
335
365
336
366
$ this ->itemMock ->expects ($ this ->once ())
337
367
->method ('addQty ' )
@@ -341,6 +371,9 @@ public function testPrepareWithResetCountAndNotStickAndOtherItemId()
341
371
->will ($ this ->returnValue ($ itemId ));
342
372
$ this ->itemMock ->expects ($ this ->never ())
343
373
->method ('setData ' );
374
+ $ this ->itemMock ->expects ($ this ->once ())
375
+ ->method ('setPrice ' )
376
+ ->will ($ this ->returnValue ($ this ->itemMock ));
344
377
345
378
$ this ->objectMock ->expects ($ this ->any ())
346
379
->method ('getCustomPrice ' )
@@ -368,6 +401,7 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
368
401
$ customPrice = 400000000 ;
369
402
$ itemId = 1 ;
370
403
$ requestItemId = 1 ;
404
+ $ finalPrice = 1000000000 ;
371
405
372
406
$ this ->objectMock ->expects ($ this ->any ())
373
407
->method ('getResetCount ' )
@@ -386,10 +420,16 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
386
420
$ this ->productMock ->expects ($ this ->any ())
387
421
->method ('getStickWithinParent ' )
388
422
->will ($ this ->returnValue (false ));
423
+ $ this ->productMock ->expects ($ this ->once ())
424
+ ->method ('getFinalPrice ' )
425
+ ->will ($ this ->returnValue ($ finalPrice ));
389
426
390
427
$ this ->itemMock ->expects ($ this ->once ())
391
428
->method ('addQty ' )
392
429
->with ($ qty );
430
+ $ this ->itemMock ->expects ($ this ->once ())
431
+ ->method ('setPrice ' )
432
+ ->will ($ this ->returnValue ($ this ->itemMock ));
393
433
394
434
$ this ->objectMock ->expects ($ this ->any ())
395
435
->method ('getCustomPrice ' )
0 commit comments