Skip to content

Commit f0869ce

Browse files
committed
ACP2E-1634: fix failing unit tests
1 parent 6535427 commit f0869ce

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

app/code/Magento/Catalog/Pricing/Price/MinimalTierPriceCalculator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function __construct(CalculatorInterface $calculator)
4343
public function getValue(SaleableInterface $saleableItem)
4444
{
4545
/** @var TierPrice $price */
46-
$price = $saleableItem->getPriceInfo()->getPrice(TierPrice::PRICE_CODE);
47-
$tierPriceList = $price->getTierPriceList();
46+
$tierPrice = $saleableItem->getPriceInfo()->getPrice(TierPrice::PRICE_CODE);
47+
$tierPriceList = $tierPrice->getTierPriceList();
4848
$finalPrice = $saleableItem->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue();
4949

5050
$minPrice = $finalPrice;

app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Test\Unit\Pricing\Price;
99

10+
use Magento\Catalog\Pricing\Price\FinalPrice;
1011
use Magento\Catalog\Pricing\Price\MinimalTierPriceCalculator;
1112
use Magento\Catalog\Pricing\Price\TierPrice;
1213
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
@@ -73,10 +74,10 @@ private function getValueTierPricesExistShouldReturnMinTierPrice()
7374
$notMinPrice = 10;
7475

7576
$minAmount = $this->getMockForAbstractClass(AmountInterface::class);
76-
$minAmount->expects($this->once())->method('getValue')->willReturn($minPrice);
77+
$minAmount->expects($this->atLeastOnce())->method('getValue')->willReturn($minPrice);
7778

7879
$notMinAmount = $this->getMockForAbstractClass(AmountInterface::class);
79-
$notMinAmount->expects($this->once())->method('getValue')->willReturn($notMinPrice);
80+
$notMinAmount->expects($this->atLeastOnce())->method('getValue')->willReturn($notMinPrice);
8081

8182
$tierPriceList = [
8283
[
@@ -89,10 +90,12 @@ private function getValueTierPricesExistShouldReturnMinTierPrice()
8990

9091
$this->price->expects($this->once())->method('getTierPriceList')->willReturn($tierPriceList);
9192

92-
$this->priceInfo->expects($this->once())->method('getPrice')->with(TierPrice::PRICE_CODE)
93-
->willReturn($this->price);
93+
$this->priceInfo->expects($this->atLeastOnce())
94+
->method('getPrice')
95+
->withConsecutive([TierPrice::PRICE_CODE], [FinalPrice::PRICE_CODE])
96+
->willReturnOnConsecutiveCalls($this->price, $notMinAmount);
9497

95-
$this->saleable->expects($this->once())->method('getPriceInfo')->willReturn($this->priceInfo);
98+
$this->saleable->expects($this->atLeastOnce())->method('getPriceInfo')->willReturn($this->priceInfo);
9699
return $minPrice;
97100
}
98101

@@ -107,12 +110,8 @@ public function testGetGetAmountMinTierPriceExistShouldReturnAmountObject()
107110
$minPrice = $this->getValueTierPricesExistShouldReturnMinTierPrice();
108111

109112
$amount = $this->getMockForAbstractClass(AmountInterface::class);
113+
$amount->method('getValue')->willReturn($minPrice);
110114

111-
$this->calculator->expects($this->once())
112-
->method('getAmount')
113-
->with($minPrice, $this->saleable)
114-
->willReturn($amount);
115-
116-
$this->assertSame($amount, $this->object->getAmount($this->saleable));
115+
$this->assertEquals($amount, $this->object->getAmount($this->saleable));
117116
}
118117
}

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ public function testRenderAmountMinimal(): void
339339
$arguments = [
340340
'zone' => 'test_zone',
341341
'list_category_page' => true,
342-
'display_label' => 'As low as',
342+
'display_label' => __('As low as'),
343343
'price_id' => $priceId,
344344
'include_container' => false,
345-
'skip_adjustments' => true
345+
'skip_adjustments' => false
346346
];
347347

348348
$amountRender = $this->createPartialMock(Amount::class, ['toHtml']);

0 commit comments

Comments
 (0)