Skip to content

Commit 660f1cf

Browse files
author
Bohdan Korablov
committed
Merge remote-tracking branch 'tango/MAGETWO-50605' into MAGETWO-51859
2 parents 809df2c + 54996e3 commit 660f1cf

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,8 @@ public function providerForGetterTierPriceList()
162162
'basePrice' => 20.,
163163
'expectedResult' => [
164164
[
165-
'price' => '50.',
166-
'website_price' => '50.',
167-
'price_qty' => '2.',
168-
'cust_group' => Group::CUST_GROUP_ALL,
169-
],
170-
[
171-
'price' => '30.',
172-
'website_price' => '30.',
165+
'price' => '15.',
166+
'website_price' => '15.',
173167
'price_qty' => '5.',
174168
'cust_group' => Group::CUST_GROUP_ALL
175169
],

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ protected function filterTierPrices(array $priceList)
162162
$qtyCache = [];
163163
$allCustomersGroupId = $this->groupManagement->getAllCustomersGroup()->getId();
164164
foreach ($priceList as $priceKey => &$price) {
165+
if ($price['price'] >= $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue()) {
166+
unset($priceList[$priceKey]);
167+
continue;
168+
}
169+
165170
if (isset($price['price_qty']) && $price['price_qty'] == 1) {
166171
unset($priceList[$priceKey]);
167172
continue;
@@ -204,7 +209,7 @@ protected function getBasePrice()
204209
public function getSavePercent(AmountInterface $amount)
205210
{
206211
return ceil(
207-
100 - ((100 / $this->priceInfo->getPrice(RegularPrice::PRICE_CODE)->getAmount()->getBaseAmount())
212+
100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue())
208213
* $amount->getBaseAmount())
209214
);
210215
}

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

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

11-
use \Magento\Catalog\Pricing\Price\TierPrice;
12-
use \Magento\Catalog\Pricing\Price\RegularPrice;
13-
11+
use Magento\Catalog\Pricing\Price\TierPrice;
12+
use Magento\Catalog\Pricing\Price\FinalPrice;
1413
use Magento\Customer\Model\Group;
1514
use Magento\Customer\Model\GroupManagement;
1615

@@ -271,6 +270,10 @@ public function testGetterTierPriceList($tierPrices, $basePrice, $expectedResult
271270
$this->calculator->expects($this->atLeastOnce())->method('getAmount')
272271
->will($this->returnArgument(0));
273272

273+
$this->priceInfo->expects(static::atLeastOnce())
274+
->method('getPrice')
275+
->with(FinalPrice::PRICE_CODE)
276+
->willReturn($price);
274277
$this->priceCurrencyMock->expects($this->any())
275278
->method('convertAndRound')
276279
->will($this->returnCallback(
@@ -365,20 +368,15 @@ public function providerForGetterTierPriceList()
365368
*/
366369
public function testGetSavePercent($basePrice, $tierPrice, $savedPercent)
367370
{
368-
$priceAmount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface');
369-
$priceAmount->expects($this->once())
370-
->method('getBaseAmount')
371-
->will($this->returnValue($basePrice));
372-
373371
$price = $this->getMock('Magento\Framework\Pricing\Price\PriceInterface');
374-
$price->expects($this->any())
375-
->method('getAmount')
376-
->will($this->returnValue($priceAmount));
377372

378-
$this->priceInfo->expects($this->atLeastOnce())
373+
$this->priceInfo->expects(static::atLeastOnce())
379374
->method('getPrice')
380-
->will($this->returnValue($price))
381-
->with(RegularPrice::PRICE_CODE);
375+
->with(FinalPrice::PRICE_CODE)
376+
->willReturn($price);
377+
$price->expects(static::atLeastOnce())
378+
->method('getValue')
379+
->willReturn($basePrice);
382380

383381
$amount = $this->getMockForAbstractClass('Magento\Framework\Pricing\Amount\AmountInterface');
384382
$amount->expects($this->atLeastOnce())

0 commit comments

Comments
 (0)