@@ -77,7 +77,16 @@ protected function setUp(): void
77
77
78
78
$ this ->itemMock = $ this ->getMockBuilder (Item::class)
79
79
->addMethods (['setOriginalCustomPrice ' ])
80
- ->onlyMethods (['getId ' , 'setOptions ' , 'setProduct ' , 'addQty ' , 'setCustomPrice ' , 'setData ' , 'setPrice ' ])
80
+ ->onlyMethods ([
81
+ 'getId ' ,
82
+ 'setOptions ' ,
83
+ 'setProduct ' ,
84
+ 'addQty ' ,
85
+ 'setCustomPrice ' ,
86
+ 'setData ' ,
87
+ 'setPrice ' ,
88
+ 'getParentItem '
89
+ ])
81
90
->disableOriginalConstructor ()
82
91
->getMock ();
83
92
$ this ->quoteItemFactoryMock ->expects ($ this ->any ())
@@ -438,4 +447,41 @@ public function testPrepareWithResetCountAndNotStickAndSameItemId()
438
447
439
448
$ this ->processor ->prepare ($ this ->itemMock , $ this ->objectMock , $ this ->productMock );
440
449
}
450
+
451
+ /**
452
+ * @param bool $isChildrenCalculated
453
+ * @dataProvider prepareChildProductDataProvider
454
+ */
455
+ public function testPrepareChildProduct (bool $ isChildrenCalculated ): void
456
+ {
457
+ $ finalPrice = 10 ;
458
+ $ this ->objectMock ->method ('getResetCount ' )
459
+ ->willReturn (false );
460
+ $ this ->productMock ->method ('getFinalPrice ' )
461
+ ->willReturn ($ finalPrice );
462
+ $ this ->itemMock ->expects ($ isChildrenCalculated ? $ this ->once () : $ this ->never ())
463
+ ->method ('setPrice ' )
464
+ ->with ($ finalPrice )
465
+ ->willReturnSelf ();
466
+ $ parentItem = $ this ->createConfiguredMock (
467
+ \Magento \Quote \Model \Quote \Item::class,
468
+ [
469
+ 'isChildrenCalculated ' => $ isChildrenCalculated
470
+ ]
471
+ );
472
+ $ this ->itemMock ->method ('getParentItem ' )
473
+ ->willReturn ($ parentItem );
474
+ $ this ->processor ->prepare ($ this ->itemMock , $ this ->objectMock , $ this ->productMock );
475
+ }
476
+
477
+ /**
478
+ * @return array
479
+ */
480
+ public function prepareChildProductDataProvider (): array
481
+ {
482
+ return [
483
+ [false ],
484
+ [true ]
485
+ ];
486
+ }
441
487
}
0 commit comments