Skip to content

Commit a92bc46

Browse files
ACP2E-403 Fixed static tests failure
1 parent 00f2141 commit a92bc46

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

app/code/Magento/Directory/Model/Observer.php

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,81 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/**
8-
* Directory module observer
9-
*
10-
* @author Magento Core Team <core@magentocommerce.com>
11-
*/
12-
137
namespace Magento\Directory\Model;
148

9+
use Magento\Backend\App\Area\FrontNameResolver;
10+
use Magento\Directory\Model\Currency\Import\Factory;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\Mail\Template\TransportBuilder;
13+
use Magento\Framework\Translate\Inline\StateInterface;
14+
use Magento\Store\Model\ScopeInterface;
15+
use Magento\Store\Model\Store;
16+
use Magento\Store\Model\StoreManagerInterface;
17+
1518
/**
16-
* Class Observer
17-
*
18-
* @package Magento\Directory\Model
19+
* Import currency rates
1920
*/
2021
class Observer
2122
{
22-
const CRON_STRING_PATH = 'crontab/default/jobs/currency_rates_update/schedule/cron_expr';
23+
public const CRON_STRING_PATH = 'crontab/default/jobs/currency_rates_update/schedule/cron_expr';
2324

24-
const IMPORT_ENABLE = 'currency/import/enabled';
25+
public const IMPORT_ENABLE = 'currency/import/enabled';
2526

26-
const IMPORT_SERVICE = 'currency/import/service';
27+
public const IMPORT_SERVICE = 'currency/import/service';
2728

28-
const XML_PATH_ERROR_TEMPLATE = 'currency/import/error_email_template';
29+
public const XML_PATH_ERROR_TEMPLATE = 'currency/import/error_email_template';
2930

30-
const XML_PATH_ERROR_IDENTITY = 'currency/import/error_email_identity';
31+
public const XML_PATH_ERROR_IDENTITY = 'currency/import/error_email_identity';
3132

32-
const XML_PATH_ERROR_RECIPIENT = 'currency/import/error_email';
33+
public const XML_PATH_ERROR_RECIPIENT = 'currency/import/error_email';
3334

3435
/**
35-
* @var \Magento\Directory\Model\Currency\Import\Factory
36+
* @var Factory
3637
*/
3738
protected $_importFactory;
3839

3940
/**
4041
* Core store config
4142
*
42-
* @var \Magento\Framework\App\Config\ScopeConfigInterface
43+
* @var ScopeConfigInterface
4344
*/
4445
protected $_scopeConfig;
4546

4647
/**
47-
* @var \Magento\Framework\Mail\Template\TransportBuilder
48+
* @var TransportBuilder
4849
*/
4950
protected $_transportBuilder;
5051

5152
/**
52-
* @var \Magento\Store\Model\StoreManagerInterface
53+
* @var StoreManagerInterface
5354
*/
5455
protected $_storeManager;
5556

5657
/**
57-
* @var \Magento\Directory\Model\CurrencyFactory
58+
* @var CurrencyFactory
5859
*/
5960
protected $_currencyFactory;
6061

6162
/**
62-
* @var \Magento\Framework\Translate\Inline\StateInterface
63+
* @var StateInterface
6364
*/
6465
protected $inlineTranslation;
6566

6667
/**
67-
* @param \Magento\Directory\Model\Currency\Import\Factory $importFactory
68-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
69-
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
70-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
71-
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
72-
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
68+
* @param Factory $importFactory
69+
* @param ScopeConfigInterface $scopeConfig
70+
* @param TransportBuilder $transportBuilder
71+
* @param StoreManagerInterface $storeManager
72+
* @param CurrencyFactory $currencyFactory
73+
* @param StateInterface $inlineTranslation
7374
*/
7475
public function __construct(
75-
\Magento\Directory\Model\Currency\Import\Factory $importFactory,
76-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
77-
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
78-
\Magento\Store\Model\StoreManagerInterface $storeManager,
79-
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
80-
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
76+
Factory $importFactory,
77+
ScopeConfigInterface $scopeConfig,
78+
TransportBuilder $transportBuilder,
79+
StoreManagerInterface $storeManager,
80+
CurrencyFactory $currencyFactory,
81+
StateInterface $inlineTranslation
8182
) {
8283
$this->_importFactory = $importFactory;
8384
$this->_scopeConfig = $scopeConfig;
@@ -94,16 +95,17 @@ public function __construct(
9495
* @return void
9596
* @throws \Exception
9697
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
98+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9799
*/
98100
public function scheduledUpdateCurrencyRates($schedule)
99101
{
100102
$importWarnings = [];
101103
if (!$this->_scopeConfig->getValue(
102104
self::IMPORT_ENABLE,
103-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
105+
ScopeInterface::SCOPE_STORE
104106
) || !$this->_scopeConfig->getValue(
105107
self::CRON_STRING_PATH,
106-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
108+
ScopeInterface::SCOPE_STORE
107109
)
108110
) {
109111
return;
@@ -113,7 +115,7 @@ public function scheduledUpdateCurrencyRates($schedule)
113115
$rates = [];
114116
$service = $this->_scopeConfig->getValue(
115117
self::IMPORT_SERVICE,
116-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
118+
ScopeInterface::SCOPE_STORE
117119
);
118120
if ($service) {
119121
try {
@@ -137,7 +139,7 @@ public function scheduledUpdateCurrencyRates($schedule)
137139

138140
$errorRecipient = $this->_scopeConfig->getValue(
139141
self::XML_PATH_ERROR_RECIPIENT,
140-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
142+
ScopeInterface::SCOPE_STORE
141143
);
142144
$errorRecipients = !empty($errorRecipient) ? explode(',', $errorRecipient) : [];
143145
if (count($importWarnings) == 0) {
@@ -149,19 +151,19 @@ public function scheduledUpdateCurrencyRates($schedule)
149151
$this->_transportBuilder->setTemplateIdentifier(
150152
$this->_scopeConfig->getValue(
151153
self::XML_PATH_ERROR_TEMPLATE,
152-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
154+
ScopeInterface::SCOPE_STORE
153155
)
154156
)->setTemplateOptions(
155157
[
156-
'area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE,
157-
'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
158+
'area' => FrontNameResolver::AREA_CODE,
159+
'store' => Store::DEFAULT_STORE_ID,
158160
]
159161
)->setTemplateVars(
160162
['warnings' => join("\n", $importWarnings)]
161163
)->setFrom(
162164
$this->_scopeConfig->getValue(
163165
self::XML_PATH_ERROR_IDENTITY,
164-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
166+
ScopeInterface::SCOPE_STORE
165167
)
166168
)->addTo($errorRecipients);
167169
$transport = $this->_transportBuilder->getTransport();

app/code/Magento/Directory/Test/Unit/Model/ObserverTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ protected function setUp(): void
106106
public function testScheduledUpdateCurrencyRates(): void
107107
{
108108
$importWarnings = ['WARNING: error1', 'WARNING: error2'];
109-
$senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER];
110109
$this->scopeConfigMock->expects($this->any())
111110
->method('getValue')
112111
->withConsecutive(
@@ -141,7 +140,6 @@ public function testScheduledUpdateCurrencyRates(): void
141140
'test1@email.com,test2@email.com',
142141
self::STUB_ERROR_TEMPLATE,
143142
self::STUB_SENDER
144-
145143
);
146144
$import = $this->getMockForAbstractClass(ImportInterface::class);
147145
$import->expects($this->once())->method('fetchRates')

0 commit comments

Comments
 (0)