Skip to content

Commit 482ba07

Browse files
committed
MAGETWO-69854: Can't set allowed or default currencies using config:set command
1 parent 33cb8d2 commit 482ba07

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Config\Console\Command\ConfigSet;
77

88
use Magento\Config\Console\Command\ConfigSetCommand;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
910
use Magento\Framework\App\Scope\ValidatorInterface;
1011
use Magento\Config\Model\Config\PathValidator;
1112
use Magento\Framework\Exception\LocalizedException;
@@ -14,6 +15,7 @@
1415
use Magento\Framework\Exception\ValidatorException;
1516
use Magento\Deploy\Model\DeploymentConfig\Hash;
1617
use Magento\Config\App\Config\Type\System;
18+
use Magento\Framework\App\Config;
1719

1820
/**
1921
* Processor facade for config:set command.
@@ -55,22 +57,32 @@ class ProcessorFacade
5557
*/
5658
private $hash;
5759

60+
/**
61+
* The application config storage.
62+
*
63+
* @var ScopeConfigInterface
64+
*/
65+
private $scopeConfig;
66+
5867
/**
5968
* @param ValidatorInterface $scopeValidator The scope validator
6069
* @param PathValidator $pathValidator The path validator
6170
* @param ConfigSetProcessorFactory $configSetProcessorFactory The factory for config:set processors
6271
* @param Hash $hash The hash manager
72+
* @param ScopeConfigInterface $scopeConfig The application config storage
6373
*/
6474
public function __construct(
6575
ValidatorInterface $scopeValidator,
6676
PathValidator $pathValidator,
6777
ConfigSetProcessorFactory $configSetProcessorFactory,
68-
Hash $hash
78+
Hash $hash,
79+
ScopeConfigInterface $scopeConfig
6980
) {
7081
$this->scopeValidator = $scopeValidator;
7182
$this->pathValidator = $pathValidator;
7283
$this->configSetProcessorFactory = $configSetProcessorFactory;
7384
$this->hash = $hash;
85+
$this->scopeConfig = $scopeConfig;
7486
}
7587

7688
/**
@@ -107,6 +119,10 @@ public function process($path, $value, $scope, $scopeCode, $lock)
107119

108120
$this->hash->regenerate(System::CONFIG_TYPE);
109121

122+
if ($this->scopeConfig instanceof Config) {
123+
$this->scopeConfig->clean();
124+
}
125+
110126
return $message;
111127
}
112128
}

app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\Exception\ConfigurationMismatchException;
1818
use Magento\Deploy\Model\DeploymentConfig\Hash;
1919
use Magento\Config\App\Config\Type\System;
20+
use Magento\Framework\App\Config;
2021
use PHPUnit_Framework_MockObject_MockObject as Mock;
2122

2223
/**
@@ -56,6 +57,11 @@ class ProcessorFacadeTest extends \PHPUnit_Framework_TestCase
5657
*/
5758
private $hashMock;
5859

60+
/**
61+
* @var Config|Mock
62+
*/
63+
private $configMock;
64+
5965
/**
6066
* @inheritdoc
6167
*/
@@ -79,12 +85,16 @@ protected function setUp()
7985
$this->hashMock = $this->getMockBuilder(Hash::class)
8086
->disableOriginalConstructor()
8187
->getMock();
88+
$this->configMock = $this->getMockBuilder(Config::class)
89+
->disableOriginalConstructor()
90+
->getMock();
8291

8392
$this->model = new ProcessorFacade(
8493
$this->scopeValidatorMock,
8594
$this->pathValidatorMock,
8695
$this->configSetProcessorFactoryMock,
87-
$this->hashMock
96+
$this->hashMock,
97+
$this->configMock
8898
);
8999
}
90100

@@ -106,6 +116,8 @@ public function testProcess()
106116
$this->hashMock->expects($this->once())
107117
->method('regenerate')
108118
->with(System::CONFIG_TYPE);
119+
$this->configMock->expects($this->once())
120+
->method('clean');
109121

110122
$this->assertSame(
111123
'Value was saved.',
@@ -156,6 +168,8 @@ public function testProcessWithConfigurationMismatchException()
156168
->willThrowException(new ConfigurationMismatchException(__('Some error')));
157169
$this->processorMock->expects($this->never())
158170
->method('process');
171+
$this->configMock->expects($this->never())
172+
->method('clean');
159173

160174
$this->model->process('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, false);
161175
}
@@ -180,6 +194,8 @@ public function testProcessWithCouldNotSaveException()
180194
->method('process')
181195
->with('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)
182196
->willThrowException(new CouldNotSaveException(__('Some error')));
197+
$this->configMock->expects($this->never())
198+
->method('clean');
183199

184200
$this->model->process('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, false);
185201
}
@@ -196,6 +212,8 @@ public function testExecuteLock()
196212
$this->processorMock->expects($this->once())
197213
->method('process')
198214
->with('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
215+
$this->configMock->expects($this->once())
216+
->method('clean');
199217

200218
$this->assertSame(
201219
'Value was saved and locked.',

0 commit comments

Comments
 (0)