Skip to content

Commit c13cada

Browse files
committed
MC-35690: [B2B] Unexpected results of editing of a Bundle Product in the Shopping Cart, added from a Requisition List
1 parent ffe6359 commit c13cada

File tree

2 files changed

+9
-44
lines changed
  • app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type
  • dev/tests/integration/testsuite/Magento/Bundle/Block/Catalog/Product/View/Type

2 files changed

+9
-44
lines changed

app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ public function testGetJsonConfigFixedPriceBundleNoOption()
214214

215215
public function testGetJsonConfigFixedPriceBundle()
216216
{
217+
$optionId = 1;
218+
$optionQty = 2;
217219
$baseAmount = 123;
218220
$basePriceValue = 123123;
219221
$selections = [
@@ -230,7 +232,6 @@ public function testGetJsonConfigFixedPriceBundle()
230232
true
231233
)
232234
];
233-
234235
$bundleProductPrice = $this->getMockBuilder(Price::class)
235236
->disableOriginalConstructor()
236237
->setMethods(['getLowestPrice'])
@@ -246,10 +247,8 @@ public function testGetJsonConfigFixedPriceBundle()
246247
$this->bundleProductPriceFactory->expects($this->once())
247248
->method('create')
248249
->willReturn($bundleProductPrice);
250+
$options = [$this->createOption($optionId, 'Title `1', $selections)];
249251

250-
$options = [
251-
$this->createOption(1, 'Title `1', $selections),
252-
];
253252
$finalPriceMock = $this->getPriceMock(
254253
[
255254
'getPriceWithoutOption' => new DataObject(
@@ -289,7 +288,10 @@ public function testGetJsonConfigFixedPriceBundle()
289288
$preconfiguredValues = new DataObject(
290289
[
291290
'bundle_option' => [
292-
1 => 123123111,
291+
$optionId => [123123111],
292+
],
293+
'bundle_option_qty' => [
294+
$optionId => $optionQty,
293295
],
294296
]
295297
);
@@ -306,7 +308,8 @@ public function testGetJsonConfigFixedPriceBundle()
306308
$this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']);
307309
$this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']);
308310
$this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']);
309-
$this->assertEquals([1], $jsonConfig['positions']);
311+
$this->assertEquals([$optionId], $jsonConfig['positions']);
312+
$this->assertEquals($optionQty, $jsonConfig['options'][$optionId]['selections'][1123]['qty']);
310313
}
311314

312315
/**

dev/tests/integration/testsuite/Magento/Bundle/Block/Catalog/Product/View/Type/BundleTest.php

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
namespace Magento\Bundle\Block\Catalog\Product\View\Type;
99

1010
use Magento\Bundle\Model\Product\Price;
11-
use Magento\Bundle\Model\Product\Type;
1211
use Magento\Catalog\Api\Data\ProductInterface;
1312
use Magento\Catalog\Api\ProductRepositoryInterface;
14-
use Magento\Catalog\Helper\Product as ProductHelper;
1513
use Magento\Framework\ObjectManagerInterface;
1614
use Magento\Framework\Registry;
1715
use Magento\Framework\Serialize\SerializerInterface;
1816
use Magento\Framework\View\LayoutInterface;
1917
use Magento\TestFramework\Helper\Bootstrap;
2018
use PHPUnit\Framework\TestCase;
21-
use Magento\Framework\DataObject\Factory as DataObjectFactory;
2219

2320
/**
2421
* Class checks bundle product view behaviour
@@ -90,41 +87,6 @@ public function testGetJsonConfig(): void
9087
$this->assertEquals(5, $selection['prices']['finalPrice']['amount']);
9188
}
9289

93-
/**
94-
* Check that selection qty is calculated correctly for Bundle config.
95-
*
96-
* @return void
97-
*/
98-
public function testGetJsonConfigWithPreconfiguredValues(): void
99-
{
100-
$optionQty = 3;
101-
$bundleProduct = $this->productRepository->get('bundle-product');
102-
$bundleSelection = $this->productRepository->get('simple');
103-
104-
/** @var Type $typeInstance */
105-
$typeInstance = $bundleProduct->getTypeInstance();
106-
$typeInstance->setStoreFilter($bundleProduct->getStoreId(), $bundleProduct);
107-
$optionCollection = $typeInstance->getOptionsCollection($bundleProduct);
108-
$optionId = $optionCollection->getFirstItem()->getId();
109-
$preconfiguredValues = $this->objectManager->get(DataObjectFactory::class)->create([
110-
'bundle_option' => [
111-
$optionId => [$bundleSelection->getId()]
112-
],
113-
'bundle_option_qty' => [
114-
$optionId => $optionQty
115-
],
116-
]);
117-
118-
/** @var ProductHelper $productHelper */
119-
$productHelper = $this->objectManager->get(ProductHelper::class);
120-
$productHelper->prepareProductOptions($bundleProduct, $preconfiguredValues);
121-
$this->registerProduct($bundleProduct);
122-
123-
$resultConfig = $this->json->unserialize($this->block->getJsonConfig());
124-
$this->assertTrue(isset($resultConfig['options'][$optionId]['selections'][$optionId]['qty']));
125-
$this->assertEquals($optionQty, $resultConfig['options'][$optionId]['selections'][$optionId]['qty']);
126-
}
127-
12890
/**
12991
* @dataProvider isSalableForStockStatusProvider
13092
*

0 commit comments

Comments
 (0)