Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 57c5d8a

Browse files
[2.3-develop] Forwardport of magento/magento2#12734
1 parent 8c705bf commit 57c5d8a

File tree

2 files changed

+16
-2
lines changed
  • app/code/Magento/Bundle
    • Controller/Adminhtml/Product/Initialization/Helper/Plugin
    • Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin

2 files changed

+16
-2
lines changed

app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function processBundleOptionsData(\Magento\Catalog\Model\Product $prod
127127
}
128128
$options = [];
129129
foreach ($bundleOptionsData as $key => $optionData) {
130-
if ((bool)$optionData['delete']) {
130+
if (!empty($optionData['delete'])) {
131131
continue;
132132
}
133133

app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
namespace Magento\Bundle\Test\Unit\Controller\Adminhtml\Product\Initialization\Helper\Plugin;
99

10+
use Magento\Catalog\Api\Data\ProductExtensionInterface;
11+
1012
class BundleTest extends \PHPUnit\Framework\TestCase
1113
{
1214
/**
@@ -57,7 +59,10 @@ protected function setUp()
5759
'setOptions',
5860
'setCanSaveBundleSelections',
5961
'__wakeup',
60-
'getOptionsReadonly'
62+
'getOptionsReadonly',
63+
'getBundleOptionsData',
64+
'getExtensionAttributes',
65+
'setExtensionAttributes',
6166
];
6267
$this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods);
6368
$optionInterfaceFactory = $this->getMockBuilder(\Magento\Bundle\Api\Data\OptionInterfaceFactory::class)
@@ -127,6 +132,15 @@ public function testAfterInitializeIfBundleAnsCustomOptionsAndBundleSelectionsEx
127132
);
128133
$this->productMock->expects($this->once())->method('setOptions')->with(null);
129134
$this->productMock->expects($this->once())->method('setCanSaveBundleSelections')->with(true);
135+
$this->productMock->expects($this->once())->method('getBundleOptionsData')->willReturn(['option_1' => ['delete' => 1]]);
136+
$extentionAttribute = $this->getMockBuilder(ProductExtensionInterface::class)
137+
->disableOriginalConstructor()
138+
->setMethods(['setBundleProductOptions'])
139+
->getMockForAbstractClass();
140+
$extentionAttribute->expects($this->once())->method('setBundleProductOptions')->with([]);
141+
$this->productMock->expects($this->once())->method('getExtensionAttributes')->willReturn($extentionAttribute);
142+
$this->productMock->expects($this->once())->method('setExtensionAttributes')->with($extentionAttribute);
143+
130144
$this->model->afterInitialize($this->subjectMock, $this->productMock);
131145
}
132146

0 commit comments

Comments
 (0)