Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 1d66e5e

Browse files
Merge forwardport of magento/magento2#13039 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/13039.patch (created by @neeta-wagento) based on commit(s): 1. 3904387 2. 5665548 3. daf95b8 4. 032242c 5. 6e060e8 6. 49df08d 7. 74901e4
2 parents 74aabb4 + 0b76fcd commit 1d66e5e

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

app/code/Magento/Quote/Model/Quote/Validator/MinimumOrderAmount/ValidationMessage.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,32 @@ class ValidationMessage
1919

2020
/**
2121
* @var \Magento\Framework\Locale\CurrencyInterface
22+
* @deprecated since 101.0.0
2223
*/
2324
private $currency;
2425

26+
/**
27+
* @var \Magento\Framework\Pricing\Helper\Data
28+
*/
29+
private $priceHelper;
30+
2531
/**
2632
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
2733
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
2834
* @param \Magento\Framework\Locale\CurrencyInterface $currency
35+
* @param \Magento\Framework\Pricing\Helper\Data $priceHelper
2936
*/
3037
public function __construct(
3138
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
3239
\Magento\Store\Model\StoreManagerInterface $storeManager,
33-
\Magento\Framework\Locale\CurrencyInterface $currency
40+
\Magento\Framework\Locale\CurrencyInterface $currency,
41+
\Magento\Framework\Pricing\Helper\Data $priceHelper = null
3442
) {
3543
$this->scopeConfig = $scopeConfig;
3644
$this->storeManager = $storeManager;
3745
$this->currency = $currency;
46+
$this->priceHelper = $priceHelper ?: \Magento\Framework\App\ObjectManager::getInstance()
47+
->get(\Magento\Framework\Pricing\Helper\Data::class);
3848
}
3949

4050
/**
@@ -50,13 +60,11 @@ public function getMessage()
5060
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
5161
);
5262
if (!$message) {
53-
$currencyCode = $this->storeManager->getStore()->getCurrentCurrencyCode();
54-
$minimumAmount = $this->currency->getCurrency($currencyCode)->toCurrency(
55-
$this->scopeConfig->getValue(
56-
'sales/minimum_order/amount',
57-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
58-
)
59-
);
63+
$minimumAmount = $this->priceHelper->currency($this->scopeConfig->getValue(
64+
'sales/minimum_order/amount',
65+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
66+
), true, false);
67+
6068
$message = __('Minimum order amount is %1', $minimumAmount);
6169
} else {
6270
//Added in order to address the issue: https://github.com/magento/magento2/issues/8287

app/code/Magento/Quote/Test/Unit/Model/Quote/Validator/MinimumOrderAmount/ValidationMessageTest.php

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,34 @@ class ValidationMessageTest extends \PHPUnit\Framework\TestCase
2626

2727
/**
2828
* @var \PHPUnit_Framework_MockObject_MockObject
29+
* @deprecated since 101.0.0
2930
*/
3031
private $currencyMock;
3132

33+
/**
34+
* @var \PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
private $priceHelperMock;
37+
3238
protected function setUp()
3339
{
3440
$this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
3541
$this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
3642
$this->currencyMock = $this->createMock(\Magento\Framework\Locale\CurrencyInterface::class);
43+
$this->priceHelperMock = $this->createMock(\Magento\Framework\Pricing\Helper\Data::class);
3744

3845
$this->model = new \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage(
3946
$this->scopeConfigMock,
4047
$this->storeManagerMock,
41-
$this->currencyMock
48+
$this->currencyMock,
49+
$this->priceHelperMock
4250
);
4351
}
4452

4553
public function testGetMessage()
4654
{
4755
$minimumAmount = 20;
4856
$minimumAmountCurrency = '$20';
49-
$currencyCode = 'currency_code';
50-
5157
$this->scopeConfigMock->expects($this->at(0))
5258
->method('getValue')
5359
->with('sales/minimum_order/description', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
@@ -58,27 +64,13 @@ public function testGetMessage()
5864
->with('sales/minimum_order/amount', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
5965
->willReturn($minimumAmount);
6066

61-
$storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getCurrentCurrencyCode']);
62-
$storeMock->expects($this->once())->method('getCurrentCurrencyCode')->willReturn($currencyCode);
63-
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
67+
$this->priceHelperMock->expects($this->once())
68+
->method('currency')
69+
->with($minimumAmount, true, false)
70+
->will($this->returnValue($minimumAmountCurrency));
6471

65-
$currencyMock = $this->createMock(\Magento\Framework\Currency::class);
66-
$this->currencyMock->expects($this->once())
67-
->method('getCurrency')
68-
->with($currencyCode)
69-
->willReturn($currencyMock);
70-
71-
$currencyMock->expects($this->once())
72-
->method('toCurrency')
73-
->with($minimumAmount)
74-
->willReturn($minimumAmountCurrency);
75-
76-
$this->assertEquals(
77-
__('Minimum order amount is %1', $minimumAmountCurrency),
78-
$this->model->getMessage()
79-
);
72+
$this->assertEquals(__('Minimum order amount is %1', $minimumAmountCurrency), $this->model->getMessage());
8073
}
81-
8274
public function testGetConfigMessage()
8375
{
8476
$configMessage = 'config_message';

0 commit comments

Comments
 (0)