Skip to content

Commit

Permalink
Fix for currency update in crontab area
Browse files Browse the repository at this point in the history
  • Loading branch information
denispapec committed Oct 31, 2018
1 parent d65f99a commit 737f396
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/Model/CurrencyConfig.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 737f396

Please sign in to comment.