Skip to content

Commit 709555d

Browse files
committed
MC-41810: Cannot add bundle product with more than 1 checkbox option to the cart via Graphql
1 parent ca4d5ba commit 709555d

File tree

1 file changed

+65
-20
lines changed

1 file changed

+65
-20
lines changed

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,16 @@ public function testPrepareForCartAdvancedWithoutOptions()
232232
/** @var MockObject|DataObject $buyRequest */
233233
$buyRequest = $this->getMockBuilder(DataObject::class)
234234
->setMethods(
235-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
235+
[
236+
'__wakeup',
237+
'getOptions',
238+
'getSuperProductConfig',
239+
'unsetData',
240+
'getData',
241+
'getQty',
242+
'getBundleOption',
243+
'getBundleOptionsData',
244+
]
236245
)
237246
->disableOriginalConstructor()
238247
->getMock();
@@ -497,7 +506,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
497506
$selection->expects($this->once())
498507
->method('getSelectionCanChangeQty')
499508
->willReturn(true);
500-
$selection->expects($this->exactly(2))
509+
$selection->expects($this->once())
501510
->method('getSelectionId');
502511
$selection->expects($this->once())
503512
->method('addCustomOption')
@@ -532,9 +541,9 @@ function ($key) use ($optionCollection, $selectionCollection) {
532541

533542
$this->arrayUtility->expects($this->once())->method('flatten')->willReturn($bundleOptions);
534543

535-
$buyRequest->expects($this->exactly(2))
536-
->method('getBundleOptionsData')
537-
->willReturn([3 => [3 => 5]]);
544+
$buyRequest->expects($this->once())
545+
->method('getBundleOptionQty')
546+
->willReturn([3 => 5]);
538547
$priceModel->expects($this->once())
539548
->method('getSelectionFinalTotalPrice')
540549
->willReturnSelf();
@@ -738,7 +747,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
738747
$selection->expects($this->once())
739748
->method('getSelectionCanChangeQty')
740749
->willReturn(true);
741-
$selection->expects($this->exactly(2))
750+
$selection->expects($this->once())
742751
->method('getSelectionId');
743752
$selection->expects($this->once())
744753
->method('addCustomOption')
@@ -770,9 +779,9 @@ function ($key) use ($optionCollection, $selectionCollection) {
770779
$option->expects($this->once())
771780
->method('getTitle')
772781
->willReturn('Title for option');
773-
$buyRequest->expects($this->exactly(2))
774-
->method('getBundleOptionsData')
775-
->willReturn([3 => [3 => 5]]);
782+
$buyRequest->expects($this->once())
783+
->method('getBundleOptionQty')
784+
->willReturn([3 => 5]);
776785
$priceModel->expects($this->once())
777786
->method('getSelectionFinalTotalPrice')
778787
->willReturnSelf();
@@ -960,7 +969,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
960969
$selection->expects($this->once())
961970
->method('getSelectionCanChangeQty')
962971
->willReturn(true);
963-
$selection->expects($this->exactly(2))
972+
$selection->expects($this->once())
964973
->method('getSelectionId');
965974
$selection->expects($this->once())
966975
->method('addCustomOption')
@@ -995,9 +1004,9 @@ function ($key) use ($optionCollection, $selectionCollection) {
9951004

9961005
$this->arrayUtility->expects($this->once())->method('flatten')->willReturn($bundleOptions);
9971006

998-
$buyRequest->expects($this->exactly(2))
999-
->method('getBundleOptionsData')
1000-
->willReturn([3 => [3 => 5]]);
1007+
$buyRequest->expects($this->once())
1008+
->method('getBundleOptionQty')
1009+
->willReturn([3 => 5]);
10011010
$priceModel->expects($this->once())
10021011
->method('getSelectionFinalTotalPrice')
10031012
->willReturnSelf();
@@ -1109,9 +1118,9 @@ function ($key) use ($optionCollection) {
11091118

11101119
$bundleOptions = [];
11111120
$buyRequest->expects($this->once())->method('getBundleOption')->willReturn($bundleOptions);
1112-
$buyRequest->expects($this->exactly(2))
1113-
->method('getBundleOptionsData')
1114-
->willReturn([3 => [3 => 5]]);
1121+
$buyRequest->expects($this->once())
1122+
->method('getBundleOptionQty')
1123+
->willReturn([3 => 5]);
11151124

11161125
$this->arrayUtility->expects($this->once())->method('flatten')->willReturn($bundleOptions);
11171126

@@ -1135,7 +1144,16 @@ public function testPrepareForCartAdvancedSelectionsSelectionIdsExists()
11351144
/** @var MockObject|DataObject $buyRequest */
11361145
$buyRequest = $this->getMockBuilder(DataObject::class)
11371146
->setMethods(
1138-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1147+
[
1148+
'__wakeup',
1149+
'getOptions',
1150+
'getSuperProductConfig',
1151+
'unsetData',
1152+
'getData',
1153+
'getQty',
1154+
'getBundleOption',
1155+
'getBundleOptionsData',
1156+
]
11391157
)
11401158
->disableOriginalConstructor()
11411159
->getMock();
@@ -1262,7 +1280,16 @@ public function testPrepareForCartAdvancedSelectRequiredOptions()
12621280
/** @var MockObject|DataObject $buyRequest */
12631281
$buyRequest = $this->getMockBuilder(DataObject::class)
12641282
->setMethods(
1265-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1283+
[
1284+
'__wakeup',
1285+
'getOptions',
1286+
'getSuperProductConfig',
1287+
'unsetData',
1288+
'getData',
1289+
'getQty',
1290+
'getBundleOption',
1291+
'getBundleOptionsData',
1292+
]
12661293
)
12671294
->disableOriginalConstructor()
12681295
->getMock();
@@ -1426,7 +1453,16 @@ public function testPrepareForCartAdvancedAllRequiredOption()
14261453
/** @var MockObject|DataObject $buyRequest */
14271454
$buyRequest = $this->getMockBuilder(DataObject::class)
14281455
->setMethods(
1429-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1456+
[
1457+
'__wakeup',
1458+
'getOptions',
1459+
'getSuperProductConfig',
1460+
'unsetData',
1461+
'getData',
1462+
'getQty',
1463+
'getBundleOption',
1464+
'getBundleOptionsData',
1465+
]
14301466
)
14311467
->disableOriginalConstructor()
14321468
->getMock();
@@ -1527,7 +1563,16 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
15271563
/** @var MockObject|DataObject $buyRequest */
15281564
$buyRequest = $this->getMockBuilder(DataObject::class)
15291565
->setMethods(
1530-
['__wakeup', 'getOptions', 'getSuperProductConfig', 'unsetData', 'getData', 'getQty', 'getBundleOption']
1566+
[
1567+
'__wakeup',
1568+
'getOptions',
1569+
'getSuperProductConfig',
1570+
'unsetData',
1571+
'getData',
1572+
'getQty',
1573+
'getBundleOption',
1574+
'getBundleOptionsData',
1575+
]
15311576
)
15321577
->disableOriginalConstructor()
15331578
->getMock();

0 commit comments

Comments
 (0)