5
5
*/
6
6
namespace Magento \Deploy \Console \Command \App ;
7
7
8
+ use Magento \Config \Model \Config \Backend \Currency \Cron ;
9
+ use Magento \Deploy \Model \DeploymentConfig \Hash ;
8
10
use Magento \Framework \App \CacheInterface ;
11
+ use Magento \Framework \App \Config \ReinitableConfigInterface ;
9
12
use Magento \Framework \App \DeploymentConfig ;
13
+ use Magento \Framework \App \Filesystem \DirectoryList ;
10
14
use Magento \Framework \Config \File \ConfigFilePool ;
15
+ use Magento \Framework \Console \Cli ;
16
+ use Magento \Framework \Filesystem ;
11
17
use Magento \Framework \Flag ;
12
18
use Magento \Framework \FlagFactory ;
19
+ use Magento \Framework \ObjectManagerInterface ;
13
20
use Magento \Store \Model \GroupFactory ;
14
21
use Magento \Store \Model \StoreFactory ;
15
22
use Magento \Store \Model \WebsiteFactory ;
16
23
use Magento \TestFramework \Helper \Bootstrap ;
17
- use Magento \Framework \ObjectManagerInterface ;
18
- use Magento \Framework \Console \Cli ;
19
- use Magento \Framework \Filesystem ;
20
- use Magento \Framework \App \Filesystem \DirectoryList ;
21
24
use Symfony \Component \Console \Tester \CommandTester ;
22
- use Magento \Deploy \Model \DeploymentConfig \Hash ;
23
- use Magento \Framework \App \Config \ReinitableConfigInterface ;
24
25
25
26
/**
26
27
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -160,7 +161,7 @@ public function testImportStores()
160
161
$ command = $ this ->objectManager ->create (ConfigImportCommand::class);
161
162
$ commandTester = new CommandTester ($ command );
162
163
163
- $ this ->runConfigImportCommand ($ commandTester );
164
+ $ this ->runConfigImportCommand ($ commandTester, ' Stores were processed ' );
164
165
165
166
/** @var StoreFactory $storeFactory */
166
167
$ storeFactory = $ this ->objectManager ->get (StoreFactory::class);
@@ -189,7 +190,7 @@ public function testImportStores()
189
190
require __DIR__ . '/../../../_files/scopes/config_with_changed_stores.php '
190
191
);
191
192
192
- $ this ->runConfigImportCommand ($ commandTester );
193
+ $ this ->runConfigImportCommand ($ commandTester, ' Stores were processed ' );
193
194
194
195
$ store = $ storeFactory ->create ();
195
196
$ store ->getResource ()->load ($ store , 'test ' , 'code ' );
@@ -212,7 +213,7 @@ public function testImportStores()
212
213
require __DIR__ . '/../../../_files/scopes/config_with_removed_stores.php '
213
214
);
214
215
215
- $ this ->runConfigImportCommand ($ commandTester );
216
+ $ this ->runConfigImportCommand ($ commandTester, ' Stores were processed ' );
216
217
217
218
$ group = $ groupFactory ->create ();
218
219
$ group ->getResource ()->load ($ group , 'test_website_store ' , 'code ' );
@@ -341,6 +342,64 @@ public function testImportConfig()
341
342
$ this ->assertSame (Cli::RETURN_SUCCESS , $ commandTester ->getStatusCode ());
342
343
}
343
344
345
+ /**
346
+ * @magentoDbIsolation disabled
347
+ */
348
+ public function testImportCurrencyImportSchedule ()
349
+ {
350
+ $ this ->assertEmpty ($ this ->hash ->get ());
351
+
352
+ $ dumpCommand = $ this ->objectManager ->create (ApplicationDumpCommand::class);
353
+ $ dumpCommandTester = new CommandTester ($ dumpCommand );
354
+ $ dumpCommandTester ->execute ([]);
355
+ $ dumpedData = $ this ->reader ->load (ConfigFilePool::APP_CONFIG );
356
+
357
+ $ command = $ this ->objectManager ->create (ConfigImportCommand::class);
358
+ $ commandTester = new CommandTester ($ command );
359
+
360
+ /** @var Cron $currencyImportSettings */
361
+ $ currencyImportSettings = $ this ->objectManager ->get (Cron::class);
362
+ /** @var $valueFactory \Magento\Framework\App\Config\ValueFactory */
363
+ $ reflectionProperty = new \ReflectionProperty (
364
+ $ currencyImportSettings ,
365
+ '_configValueFactory '
366
+ );
367
+ $ reflectionProperty ->setAccessible (true );
368
+ $ valueFactory = $ reflectionProperty ->getValue ($ currencyImportSettings );
369
+ /** @var $configValue \Magento\Framework\App\Config\ValueInterface */
370
+ $ configValue = $ valueFactory ->create ();
371
+
372
+ $ hour = rand (0 , 23 );
373
+ $ min = rand (0 , 59 );
374
+ $ data = [
375
+ 'system ' => [
376
+ 'default ' => [
377
+ 'currency ' => [
378
+ 'import ' => [
379
+ 'enabled ' => '1 ' ,
380
+ 'service ' => 'fixerio ' ,
381
+ 'time ' => sprintf ("%02d " , $ hour ) . ', ' . sprintf ("%02d " , $ min ) . ',00 ' ,
382
+ 'frequency ' => 'D ' ,
383
+ 'error_email_identity ' => 'general ' ,
384
+ 'error_email_template ' => 'currency_import_error_email_template ' ,
385
+ ],
386
+ ],
387
+ ],
388
+ ]
389
+ ];
390
+
391
+ $ this ->writeConfig (
392
+ $ dumpedData ,
393
+ $ data
394
+ );
395
+ $ this ->runConfigImportCommand ($ commandTester , 'System config was processed ' );
396
+
397
+ $ configValue ->load (Cron::CRON_STRING_PATH , Cron::CONFIG_FIELD );
398
+ $ configValue ->getFieldsetDataValue (Cron::CONFIG_FIELD );
399
+ $ time = $ configValue ->getValue ();
400
+ $ this ->assertSame ($ time , "$ min $ hour * * * " );
401
+ }
402
+
344
403
/**
345
404
* Saves new data.
346
405
*
@@ -393,7 +452,7 @@ private function loadEnvConfig()
393
452
*
394
453
* @param $commandTester
395
454
*/
396
- private function runConfigImportCommand ($ commandTester )
455
+ private function runConfigImportCommand ($ commandTester, $ assertPartialString )
397
456
{
398
457
$ this ->appConfig ->reinit ();
399
458
$ commandTester ->execute ([], ['interactive ' => false ]);
@@ -402,7 +461,7 @@ private function runConfigImportCommand($commandTester)
402
461
'Processing configurations data from configuration file... ' ,
403
462
$ commandTester ->getDisplay ()
404
463
);
405
- $ this ->assertStringContainsString (' Stores were processed ' , $ commandTester ->getDisplay ());
464
+ $ this ->assertStringContainsString ($ assertPartialString , $ commandTester ->getDisplay ());
406
465
$ this ->assertSame (Cli::RETURN_SUCCESS , $ commandTester ->getStatusCode ());
407
466
}
408
467
}
0 commit comments