From 6b9c188627aa4d9614c5ffe1a0436d75e17bb796 Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko Date: Mon, 29 Jan 2018 15:36:13 -0600 Subject: [PATCH] magento/magento2#11809: 8003: Using System Value for Base Currency Results in Config Error. - removed redundant files --- .../Directory/Model/CurrencySystemConfig.php | 123 ----------------- .../Model/CurrencySystemConfigTest.php | 130 ------------------ 2 files changed, 253 deletions(-) delete mode 100644 app/code/Magento/Directory/Model/CurrencySystemConfig.php delete mode 100644 dev/tests/integration/testsuite/Magento/Directory/Model/CurrencySystemConfigTest.php diff --git a/app/code/Magento/Directory/Model/CurrencySystemConfig.php b/app/code/Magento/Directory/Model/CurrencySystemConfig.php deleted file mode 100644 index ce2829a489b4b..0000000000000 --- a/app/code/Magento/Directory/Model/CurrencySystemConfig.php +++ /dev/null @@ -1,123 +0,0 @@ -systemConfig = $systemConfig; - $this->storeManager = $storeManager; - } - - /** - * Retrieve config currency data by config path. - * - * @param string $path - * @return array - */ - public function getConfigCurrencies(string $path) - { - $this->path = $path; - $result = array_merge( - $this->getDefaultConfigCurrencies(), - $this->getWebsiteConfigCurrencies(), - $this->getStoreConfigCurrencies() - ); - sort($result); - - return array_unique($result); - } - - /** - * Get system config values as array for default scope. - * - * @return array - */ - private function getDefaultConfigCurrencies() - { - return $this->getConfig($this->path, 'default'); - } - - /** - * Get system config values as array for website scope. - * - * @return array - */ - private function getWebsiteConfigCurrencies() - { - $websiteResult = [[]]; - foreach ($this->storeManager->getWebsites() as $website) { - $websiteResult[] = $this->getConfig($this->path, 'websites', $website->getId()); - } - $websiteResult = array_merge(...$websiteResult); - - return $websiteResult; - } - - /** - * Get system config values as array for store scope. - * - * @return array - */ - private function getStoreConfigCurrencies() - { - $storeResult = [[]]; - foreach ($this->storeManager->getStores() as $store) { - $storeResult[] = $this->getConfig($this->path, 'stores', $store->getId()); - } - $storeResult = array_merge(...$storeResult); - - return $storeResult; - } - - /** - * Get system config values as array for specified scope. - * - * @param string $scope - * @param string $scopeId - * @param string $path - * @return array - */ - private function getConfig(string $path, string $scope, string $scopeId = null) - { - $configPath = $scopeId ? sprintf('%s/%s/%s', $scope, $scopeId, $path) : sprintf('%s/%s', $scope, $path); - - return explode(',', $this->systemConfig->get($configPath)); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/CurrencySystemConfigTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/CurrencySystemConfigTest.php deleted file mode 100644 index e01fd1f5deff9..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Directory/Model/CurrencySystemConfigTest.php +++ /dev/null @@ -1,130 +0,0 @@ -currency = Bootstrap::getObjectManager()->get(CurrencyModel::class); - $this->configResource = Bootstrap::getObjectManager()->get(ConfigInterface::class); - } - - /** - * Test CurrencySystemConfig won't read system config, if values present in DB. - */ - public function testGetConfigCurrenciesWithDbValues() - { - $this->clearCurrencyConfig(); - $allowedCurrencies = 'BDT,BNS,BTD,USD'; - $baseCurrency = 'BDT'; - $this->configResource->saveConfig( - $this->baseCurrencyPath, - $baseCurrency, - ScopeInterface::SCOPE_STORE, - 0 - ); - $this->configResource->saveConfig( - $this->defaultCurrencyPath, - $baseCurrency, - ScopeInterface::SCOPE_STORE, - 0 - ); - $this->configResource->saveConfig( - $this->allowedCurrenciesPath, - $allowedCurrencies, - ScopeInterface::SCOPE_STORE, - 0 - ); - - $expected = [ - 'allowed' => explode(',', $allowedCurrencies), - 'base' => [$baseCurrency], - 'default' => [$baseCurrency], - ]; - self::assertEquals($expected['allowed'], $this->currency->getConfigAllowCurrencies()); - self::assertEquals($expected['base'], $this->currency->getConfigBaseCurrencies()); - self::assertEquals($expected['default'], $this->currency->getConfigDefaultCurrencies()); - } - - /** - * Test CurrencySystemConfig will read system config, if values don't present in DB. - */ - public function testGetConfigCurrenciesWithNoDbValues() - { - $this->clearCurrencyConfig(); - $expected = [ - 'allowed' => [0 => 'EUR',3 => 'USD'], - 'base' => ['USD'], - 'default' => ['USD'], - ]; - self::assertEquals($expected['allowed'], $this->currency->getConfigAllowCurrencies()); - self::assertEquals($expected['base'], $this->currency->getConfigBaseCurrencies()); - self::assertEquals($expected['default'], $this->currency->getConfigDefaultCurrencies()); - } - - /** - * Remove currency config form Db. - * - * @return void - */ - private function clearCurrencyConfig() - { - $this->configResource->deleteConfig( - $this->allowedCurrenciesPath, - ScopeInterface::SCOPE_STORE, - 0 - ); - $this->configResource->deleteConfig( - $this->baseCurrencyPath, - ScopeInterface::SCOPE_STORE, - 0 - ); - $this->configResource->deleteConfig( - $this->defaultCurrencyPath, - ScopeInterface::SCOPE_STORE, - 0 - ); - } -}