33 private $_globalConfigValues = [];
40 private $_storeConfigValues = [];
49 protected function _getConfigValue($configPath, $scopeCode =
null)
53 if ($scopeCode !==
false) {
56 $result = $scopeConfig->getValue(
58 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE,
76 if (strpos($configPath,
'default/') === 0) {
77 $configPath = substr($configPath, 8);
92 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE,
106 $annotations = $test->getAnnotations();
107 if (!isset($annotations[
'method'][
'magentoConfigFixture'])) {
110 foreach ($annotations[
'method'][
'magentoConfigFixture'] as $configPathAndValue) {
111 if (preg_match(
'/^.+?(?=_store\s)/', $configPathAndValue, $matches)) {
113 $storeCode = $matches[0] !=
'current' ? $matches[0] :
null;
114 $parts = preg_split(
'/\s+/', $configPathAndValue, 3);
115 list($configScope, $configPath, $requiredValue) = $parts + [
'',
'',
''];
116 $originalValue = $this->_getConfigValue($configPath,
$storeCode);
117 $this->_storeConfigValues[
$storeCode][$configPath] = $originalValue;
121 list($configPath, $requiredValue) = preg_split(
'/\s+/', $configPathAndValue, 2);
123 $originalValue = $this->_getConfigValue($configPath);
124 $this->_globalConfigValues[$configPath] = $originalValue;
137 foreach ($this->_globalConfigValues as $configPath => $originalValue) {
140 $this->_globalConfigValues = [];
143 foreach ($this->_storeConfigValues as
$storeCode => $originalData) {
144 foreach ($originalData as $configPath => $originalValue) {
151 $this->_storeConfigValues = [];
159 public function startTest(\PHPUnit\Framework\TestCase $test)
161 $this->_currentTest = $test;
172 public function endTest(\PHPUnit\Framework\TestCase $test)
174 $this->_currentTest =
null;
184 if ($this->_currentTest) {
_assignConfigData(\PHPUnit\Framework\TestCase $test)
endTest(\PHPUnit\Framework\TestCase $test)
_setConfigValue($configPath, $value, $storeCode=false)
startTest(\PHPUnit\Framework\TestCase $test)
static getObjectManager()