6
6
7
7
namespace Magento \Config \Console \Command ;
8
8
9
+ use Magento \Config \Model \Config \Structure ;
9
10
use Magento \Framework \App \DeploymentConfig \FileReader ;
10
11
use Magento \Framework \App \DeploymentConfig \Writer ;
11
12
use Magento \Framework \App \Filesystem \DirectoryList ;
12
13
use Magento \Framework \Config \File \ConfigFilePool ;
13
14
use Magento \Framework \Console \Cli ;
14
15
use Magento \Framework \Filesystem ;
15
- use Magento \Framework \ObjectManagerInterface ;
16
16
use Magento \Store \Model \ScopeInterface ;
17
17
use Magento \TestFramework \Helper \Bootstrap ;
18
+ use PHPUnit \Framework \TestCase ;
18
19
use Symfony \Component \Console \Tester \CommandTester ;
19
20
20
- class ConfigShowCommandTest extends \PHPUnit \Framework \TestCase
21
+ /**
22
+ * Test for \Magento\Config\Console\Command\ConfigShowCommand.
23
+ */
24
+ class ConfigShowCommandTest extends TestCase
21
25
{
22
- /**
23
- * @var ObjectManagerInterface
24
- */
25
- private $ objectManager ;
26
-
27
26
/**
28
27
* @var CommandTester
29
28
*/
@@ -64,16 +63,22 @@ class ConfigShowCommandTest extends \PHPUnit\Framework\TestCase
64
63
*/
65
64
private $ envConfig ;
66
65
66
+ /**
67
+ * @var Structure
68
+ */
69
+ private $ structure ;
70
+
67
71
/**
68
72
* @inheritdoc
69
73
*/
70
74
protected function setUp (): void
71
75
{
72
- $ this ->objectManager = Bootstrap::getObjectManager ();
73
- $ this ->configFilePool = $ this ->objectManager ->get (ConfigFilePool::class);
74
- $ this ->filesystem = $ this ->objectManager ->get (Filesystem::class);
75
- $ this ->reader = $ this ->objectManager ->get (FileReader::class);
76
- $ this ->writer = $ this ->objectManager ->get (Writer::class);
76
+ $ objectManager = Bootstrap::getObjectManager ();
77
+ $ this ->configFilePool = $ objectManager ->get (ConfigFilePool::class);
78
+ $ this ->filesystem = $ objectManager ->get (Filesystem::class);
79
+ $ this ->reader = $ objectManager ->get (FileReader::class);
80
+ $ this ->writer = $ objectManager ->get (Writer::class);
81
+ $ this ->structure = $ objectManager ->get (Structure::class);
77
82
78
83
$ this ->config = $ this ->loadConfig ();
79
84
$ this ->envConfig = $ this ->loadEnvConfig ();
@@ -89,21 +94,27 @@ protected function setUp(): void
89
94
$ _ENV ['CONFIG__WEBSITES__BASE__WEB__TEST2__TEST_VALUE_4 ' ] = 'value4.env.website_base.test ' ;
90
95
$ _ENV ['CONFIG__STORES__DEFAULT__WEB__TEST2__TEST_VALUE_4 ' ] = 'value4.env.store_default.test ' ;
91
96
92
- $ command = $ this -> objectManager ->create (ConfigShowCommand::class);
97
+ $ command = $ objectManager ->create (ConfigShowCommand::class);
93
98
$ this ->commandTester = new CommandTester ($ command );
94
99
}
95
100
96
101
/**
102
+ * Test execute config show command
103
+ *
97
104
* @param string $scope
98
105
* @param string $scopeCode
99
106
* @param int $resultCode
100
107
* @param array $configs
108
+ * @return void
109
+ *
101
110
* @magentoDbIsolation enabled
102
111
* @magentoDataFixture Magento/Config/_files/config_data.php
103
112
* @dataProvider executeDataProvider
104
113
*/
105
- public function testExecute ($ scope , $ scopeCode , $ resultCode , array $ configs )
114
+ public function testExecute ($ scope , $ scopeCode , $ resultCode , array $ configs ): void
106
115
{
116
+ $ this ->setConfigPaths ();
117
+
107
118
foreach ($ configs as $ inputPath => $ configValue ) {
108
119
$ arguments = [
109
120
ConfigShowCommand::INPUT_ARGUMENT_PATH => $ inputPath
@@ -130,6 +141,41 @@ public function testExecute($scope, $scopeCode, $resultCode, array $configs)
130
141
}
131
142
}
132
143
144
+ /**
145
+ * Set config paths to structure
146
+ *
147
+ * @return void
148
+ */
149
+ private function setConfigPaths (): void
150
+ {
151
+ $ reflection = new \ReflectionClass (Structure::class);
152
+ $ mappedPaths = $ reflection ->getProperty ('mappedPaths ' );
153
+ $ mappedPaths ->setAccessible (true );
154
+ $ mappedPaths ->setValue ($ this ->structure , $ this ->getConfigPaths ());
155
+ }
156
+
157
+ /**
158
+ * Returns config paths
159
+ *
160
+ * @return array
161
+ */
162
+ private function getConfigPaths (): array
163
+ {
164
+ $ configs = [
165
+ 'web/test/test_value_1 ' ,
166
+ 'web/test/test_value_2 ' ,
167
+ 'web/test2/test_value_3 ' ,
168
+ 'web/test2/test_value_4 ' ,
169
+ 'carriers/fedex/account ' ,
170
+ 'paypal/fetch_reports/ftp_password ' ,
171
+ 'web/test ' ,
172
+ 'web/test2 ' ,
173
+ 'web ' ,
174
+ ];
175
+
176
+ return array_flip ($ configs );
177
+ }
178
+
133
179
/**
134
180
* @return array
135
181
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -240,7 +286,7 @@ public function executeDataProvider()
240
286
Cli::RETURN_FAILURE ,
241
287
[
242
288
'web/test/test_wrong_value ' => [
243
- 'Configuration for path: "web/test/test_wrong_value" doesn \'t exist '
289
+ 'The "web/test/test_wrong_value" path doesn \'t exist. Verify and try again. '
244
290
],
245
291
]
246
292
],
@@ -250,7 +296,7 @@ public function executeDataProvider()
250
296
Cli::RETURN_FAILURE ,
251
297
[
252
298
'web/test/test_wrong_value ' => [
253
- 'Configuration for path: "web/test/test_wrong_value" doesn \'t exist '
299
+ 'The "web/test/test_wrong_value" path doesn \'t exist. Verify and try again. '
254
300
],
255
301
]
256
302
],
0 commit comments