Skip to content

Commit 037c514

Browse files
Chhandak.BaruaChhandak.Barua
authored andcommitted
ACP2E-2515: Cart Price Rule stops working properly after adding Bundle Product to the cart with Dynamic Price attribute disabled
1 parent be2ce3a commit 037c514

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

app/code/Magento/OfflineShipping/Test/Unit/Model/Carrier/TablerateTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ protected function setUp(): void
118118

119119
/**
120120
* @param bool $freeshipping
121+
* @param bool $isShipSeparately
121122
* @dataProvider collectRatesWithGlobalFreeShippingDataProvider
122123
* @return void
123124
*/
124-
public function testCollectRatesWithGlobalFreeShipping($freeshipping)
125+
public function testCollectRatesWithGlobalFreeShipping($freeshipping, $isShipSeparately)
125126
{
126127
$rate = [
127128
'price' => 15,
@@ -177,11 +178,17 @@ public function testCollectRatesWithGlobalFreeShipping($freeshipping)
177178
$this->resultFactoryMock->expects($this->once())->method('create')->willReturn($result);
178179

179180
$product->expects($this->any())->method('isVirtual')->willReturn(false);
180-
181181
$item->expects($this->any())->method('getProduct')->willReturn($product);
182-
$item->expects($this->any())->method('getFreeShipping')->willReturn(1);
183182
$item->expects($this->any())->method('getQty')->willReturn(1);
184-
183+
if ($isShipSeparately) {
184+
$freeShippingReturnValue = true;
185+
$item->expects($this->any())->method('getHasChildren')->willReturn(1);
186+
$item->expects($this->any())->method('isShipSeparately')->willReturn(1);
187+
$item->expects($this->any())->method('getChildren')->willReturn([$item]);
188+
} else {
189+
$freeShippingReturnValue = 1;
190+
}
191+
$item->expects($this->any())->method('getFreeShipping')->willReturn($freeShippingReturnValue);
185192
$request->expects($this->any())->method('getAllItems')->willReturn([$item]);
186193
$request->expects($this->any())->method('getPackageQty')->willReturn(1);
187194

@@ -225,8 +232,9 @@ private function captureArg(&$captureVar)
225232
public function collectRatesWithGlobalFreeShippingDataProvider()
226233
{
227234
return [
228-
['freeshipping' => true],
229-
['freeshipping' => false]
235+
['freeshipping' => true, 'isShipSeparately' => false],
236+
['freeshipping' => false, 'isShipSeparately' => false],
237+
['freeshipping' => true, 'isShipSeparately' => true]
230238
];
231239
}
232240
}

0 commit comments

Comments
 (0)