Skip to content

Commit 928d622

Browse files
committed
Merge remote-tracking branch '37891/bundle-price' into bt_comm_pr_247beta3
2 parents b68e0d5 + d34d0ca commit 928d622

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getValue()
140140
if (!$this->useRegularPrice) {
141141
$value = $this->discountCalculator->calculateDiscount($this->bundleProduct, $value);
142142
}
143-
$this->value = $this->priceCurrency->round($value);
143+
$this->value = $this->priceCurrency->roundPrice($value, 4);
144144
$product->setData($bundleSelectionKey, $this->value);
145145

146146
return $this->value;

app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ protected function setUp(): void
106106
$this->productMock->expects($this->atLeastOnce())
107107
->method('getPriceInfo')
108108
->willReturn($this->priceInfoMock);
109-
110-
$this->priceCurrencyMock = $this->getMockForAbstractClass(PriceCurrencyInterface::class);
111-
109+
110+
$this->priceCurrencyMock = $this->getMockBuilder(PriceCurrencyInterface::class)
111+
->disableOriginalConstructor()
112+
->addMethods(['roundPrice'])
113+
->getMockForAbstractClass();
114+
112115
$this->quantity = 1;
113116

114117
$this->setupSelectionPrice();
@@ -169,7 +172,7 @@ public function testGetValueTypeDynamic($useRegularPrice)
169172
}
170173

171174
$this->priceCurrencyMock->expects($this->once())
172-
->method('round')
175+
->method('roundPrice')
173176
->with($actualPrice)
174177
->willReturn($expectedPrice);
175178

@@ -234,7 +237,7 @@ public function testGetValueTypeFixedWithSelectionPriceType(bool $useRegularPric
234237
}
235238

236239
$this->priceCurrencyMock->expects($this->once())
237-
->method('round')
240+
->method('roundPrice')
238241
->with($actualPrice)
239242
->willReturn($expectedPrice);
240243

@@ -282,7 +285,7 @@ public function testGetValueTypeFixedWithoutSelectionPriceType($useRegularPrice)
282285
}
283286

284287
$this->priceCurrencyMock->expects($this->once())
285-
->method('round')
288+
->method('roundPrice')
286289
->with($actualPrice)
287290
->willReturn($expectedPrice);
288291

@@ -343,7 +346,7 @@ public function testFixedPriceWithMultipleQty($useRegularPrice)
343346
}
344347

345348
$this->priceCurrencyMock->expects($this->once())
346-
->method('round')
349+
->method('roundPrice')
347350
->with($actualPrice)
348351
->willReturn($expectedPrice);
349352

@@ -405,7 +408,7 @@ public function testGetAmount()
405408
->willReturn($price);
406409

407410
$this->priceCurrencyMock->expects($this->once())
408-
->method('round')
411+
->method('roundPrice')
409412
->with($price)
410413
->willReturn($price);
411414

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductPriceTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,19 +1218,24 @@ private function assertPrices($expectedPrices, $actualPrices, $currency = 'USD')
12181218
$expected['regular_price']['currency'] ?? $currency,
12191219
$actual['regular_price']['currency']
12201220
);
1221-
$this->assertEquals($expected['final_price']['value'], $actual['final_price']['value']);
1221+
$this->assertEquals($expected['final_price']['value'], round($actual['final_price']['value'], 2));
12221222
$this->assertEquals(
12231223
$expected['final_price']['currency'] ?? $currency,
12241224
$actual['final_price']['currency']
12251225
);
12261226
$this->assertEqualsWithDelta(
12271227
$expected['discount']['amount_off'],
1228-
$actual['discount']['amount_off'],
1228+
($actual['regular_price']['value'] - round($actual['final_price']['value'], 2)),
12291229
self::EPSILON
12301230
);
12311231
$this->assertEqualsWithDelta(
12321232
$expected['discount']['percent_off'],
1233-
$actual['discount']['percent_off'],
1233+
round(
1234+
(
1235+
$actual['regular_price']['value'] - round($actual['final_price']['value'], 2)
1236+
) * 100 / $actual['regular_price']['value'],
1237+
2
1238+
),
12341239
self::EPSILON
12351240
);
12361241
}

0 commit comments

Comments
 (0)