Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Fix for currency update in crontab area #18980

Merged
merged 1 commit into from Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/CurrencyConfig.php
Expand Up @@ -57,7 +57,7 @@ public function __construct(
*/
public function getConfigCurrencies(string $path)
{
$result = $this->appState->getAreaCode() === Area::AREA_ADMINHTML
$result = in_array($this->appState->getAreaCode(), [Area::AREA_ADMINHTML, Area::AREA_CRONTAB])
? $this->getConfigForAllStores($path)
: $this->getConfigForCurrentStore($path);
sort($result);
Expand Down
Expand Up @@ -68,7 +68,7 @@ protected function setUp()
}

/**
* Test get currency config for admin and storefront areas.
* Test get currency config for admin, crontab and storefront areas.
*
* @dataProvider getConfigCurrenciesDataProvider
* @return void
Expand All @@ -91,7 +91,7 @@ public function testGetConfigCurrencies(string $areCode)
->method('getCode')
->willReturn('testCode');

if ($areCode === Area::AREA_ADMINHTML) {
if (in_array($areCode, [Area::AREA_ADMINHTML, Area::AREA_CRONTAB])) {
$this->storeManager->expects(self::once())
->method('getStores')
->willReturn([$store]);
Expand Down Expand Up @@ -121,6 +121,7 @@ public function getConfigCurrenciesDataProvider()
{
return [
['areaCode' => Area::AREA_ADMINHTML],
['areaCode' => Area::AREA_CRONTAB],
['areaCode' => Area::AREA_FRONTEND],
];
}
Expand Down
Expand Up @@ -56,7 +56,7 @@ protected function setUp()
}

/**
* Test get currency config for admin and storefront areas.
* Test get currency config for admin, crontab and storefront areas.
*
* @dataProvider getConfigCurrenciesDataProvider
* @magentoDataFixture Magento/Store/_files/store.php
Expand All @@ -77,7 +77,7 @@ public function testGetConfigCurrencies(string $areaCode, array $expected)
$storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class);
$storeManager->setCurrentStore($store->getId());

if ($areaCode === Area::AREA_ADMINHTML) {
if (in_array($areaCode, [Area::AREA_ADMINHTML, Area::AREA_CRONTAB])) {
self::assertEquals($expected['allowed'], $this->currency->getConfigAllowCurrencies());
self::assertEquals($expected['base'], $this->currency->getConfigBaseCurrencies());
self::assertEquals($expected['default'], $this->currency->getConfigDefaultCurrencies());
Expand Down Expand Up @@ -118,6 +118,14 @@ public function getConfigCurrenciesDataProvider()
'default' => ['BDT', 'USD'],
],
],
[
'areaCode' => Area::AREA_CRONTAB,
'expected' => [
'allowed' => ['BDT', 'BNS', 'BTD', 'EUR', 'USD'],
'base' => ['BDT', 'USD'],
'default' => ['BDT', 'USD'],
],
],
[
'areaCode' => Area::AREA_FRONTEND,
'expected' => [
Expand Down