Skip to content

Commit 5319521

Browse files
author
Anna Bukatar
committed
ACP2E-456: Mexican currency symbol (MX$) is not displayed for es_MX locale
1 parent f1adf23 commit 5319521

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ public function getCurrencySymbolsData()
174174

175175
if (isset($currentSymbols[$code]) && !empty($currentSymbols[$code])) {
176176
$this->_symbolsData[$code]['displaySymbol'] = $currentSymbols[$code];
177+
$this->_symbolsData[$code]['inherited'] = false;
177178
} else {
178179
$this->_symbolsData[$code]['displaySymbol'] = $this->_symbolsData[$code]['parentSymbol'];
180+
$this->_symbolsData[$code]['inherited'] = true;
179181
}
180-
$this->_symbolsData[$code]['inherited'] =
181-
($this->_symbolsData[$code]['parentSymbol'] == $this->_symbolsData[$code]['displaySymbol']);
182182
}
183183

184184
return $this->_symbolsData;
@@ -194,7 +194,7 @@ public function setCurrencySymbolsData($symbols = [])
194194
{
195195
if (!$this->_storeManager->isSingleStoreMode()) {
196196
foreach ($this->getCurrencySymbolsData() as $code => $values) {
197-
if (isset($symbols[$code]) && ($symbols[$code] == $values['parentSymbol'] || empty($symbols[$code]))) {
197+
if (isset($symbols[$code]) && empty($symbols[$code])) {
198198
unset($symbols[$code]);
199199
}
200200
}

dev/tests/integration/testsuite/Magento/CurrencySymbol/Model/System/CurrencysymbolTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,31 @@ class CurrencysymbolTest extends \PHPUnit\Framework\TestCase
2020
*/
2121
protected $currencySymbolModel;
2222

23+
/**
24+
* @inheirtDoc
25+
*/
2326
protected function setUp(): void
2427
{
2528
$this->currencySymbolModel = Bootstrap::getObjectManager()->create(
2629
\Magento\CurrencySymbol\Model\System\Currencysymbol::class
2730
);
2831
}
2932

33+
/**
34+
* @inheirtDoc
35+
*/
3036
protected function tearDown(): void
3137
{
3238
$this->currencySymbolModel = null;
3339
Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class)->reinit();
3440
Bootstrap::getObjectManager()->create(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores();
3541
}
3642

43+
/**
44+
* Test that getCurrencySymbolsData method returns valid data
45+
*
46+
* @return void
47+
*/
3748
public function testGetCurrencySymbolsData()
3849
{
3950
$currencySymbolsData = $this->currencySymbolModel->getCurrencySymbolsData();
@@ -80,8 +91,37 @@ public function testSetCurrencySymbolsData()
8091
$this->assertEquals('@', $this->currencySymbolModel->getCurrencySymbol('EUR'), 'Symbol not set correctly.');
8192
}
8293

94+
/**
95+
* Test that method returns valid data
96+
*
97+
* @return void
98+
*/
8399
public function testGetCurrencySymbolNonExistent()
84100
{
85101
$this->assertFalse($this->currencySymbolModel->getCurrencySymbol('AUD'));
86102
}
103+
104+
/**
105+
* Test that default symbol can be set to use explicitly in the system
106+
*
107+
* @return void
108+
*/
109+
public function testSetCurrencySymbolLikeParent()
110+
{
111+
$currencySymbolsData = ['USD' => '$'];
112+
$this->currencySymbolModel->setCurrencySymbolsData($currencySymbolsData);
113+
114+
//Verify if the new symbol is set
115+
$this->assertEquals(
116+
'$',
117+
$this->currencySymbolModel->getCurrencySymbolsData()['USD']['displaySymbol'],
118+
'Symbol was not correctly set.'
119+
);
120+
121+
$this->assertEquals(
122+
false,
123+
$this->currencySymbolModel->getCurrencySymbolsData()['USD']['inherited'],
124+
'Symbol\'s inheritance was not correctly set.'
125+
);
126+
}
87127
}

0 commit comments

Comments
 (0)