5
5
*/
6
6
namespace Magento \Config \Console \Command ;
7
7
8
- use Magento \Config \Console \Command \ConfigShow \ConfigSourceAggregated ;
9
- use Magento \Framework \App \Config \ScopePathResolver ;
10
8
use Magento \Store \Model \ScopeInterface ;
11
9
use Magento \TestFramework \Helper \Bootstrap ;
12
10
use Magento \Framework \App \Config \ScopeConfigInterface ;
@@ -22,26 +20,13 @@ class ConfigShowCommandTest extends \PHPUnit_Framework_TestCase
22
20
private $ objectManager ;
23
21
24
22
/**
25
- * @var ConfigSourceAggregated
26
- */
27
- private $ config ;
28
-
29
- /**
30
- * @var CommandTester
31
- */
23
+ * @var CommandTester
24
+ */
32
25
private $ commandTester ;
33
26
34
- /**
35
- * @var ScopePathResolver
36
- */
37
- private $ pathResolver ;
38
-
39
27
public function setUp ()
40
28
{
41
29
$ this ->objectManager = Bootstrap::getObjectManager ();
42
- $ this ->config = $ this ->objectManager ->get (ConfigSourceAggregated::class);
43
- $ this ->pathResolver = $ this ->objectManager ->get (ScopePathResolver::class);
44
-
45
30
$ command = $ this ->objectManager ->create (ConfigShowCommand::class);
46
31
$ this ->commandTester = new CommandTester ($ command );
47
32
}
@@ -52,7 +37,7 @@ public function setUp()
52
37
* @param array $configs
53
38
* @magentoDbIsolation enabled
54
39
* @magentoDataFixture Magento/Config/_files/config_data.php
55
- * @dataProvider testExecuteDataProvider
40
+ * @dataProvider executeDataProvider
56
41
*/
57
42
public function testExecute ($ scope , $ scopeCode , array $ configs )
58
43
{
@@ -70,48 +55,57 @@ public function testExecute($scope, $scopeCode, array $configs)
70
55
71
56
$ this ->commandTester ->execute ($ arguments );
72
57
73
- $ configPath = $ this ->pathResolver ->resolve ($ inputPath , $ scope , $ scopeCode );
74
- $ appConfigValue = $ this ->config ->get ($ configPath );
75
58
$ this ->assertEquals (
76
59
Cli::RETURN_SUCCESS ,
77
60
$ this ->commandTester ->getStatusCode ()
78
61
);
79
- $ this ->assertEquals (
80
- $ configValue ,
81
- $ appConfigValue
82
- );
83
62
$ this ->assertContains (
84
- $ appConfigValue ,
63
+ $ configValue ,
85
64
$ this ->commandTester ->getDisplay ()
86
65
);
87
66
}
88
67
}
89
68
90
69
/**
70
+ * @param string $scope
71
+ * @param string $scopeCode
72
+ * @param array $configs
91
73
* @magentoDbIsolation enabled
92
74
* @magentoDataFixture Magento/Config/_files/config_data.php
75
+ * @dataProvider executeDataProvider
93
76
*/
94
- public function testExecuteConfigGroup ()
77
+ public function testExecuteConfigGroup ($ scope , $ scopeCode , array $ configs )
95
78
{
96
- $ this -> commandTester -> execute ( [
79
+ $ arguments = [
97
80
ConfigShowCommand::INPUT_ARGUMENT_PATH => 'web/test '
98
- ]);
81
+ ];
82
+
83
+ if ($ scope !== null ) {
84
+ $ arguments ['-- ' . ConfigShowCommand::INPUT_OPTION_SCOPE ] = $ scope ;
85
+ }
86
+ if ($ scopeCode !== null ) {
87
+ $ arguments ['-- ' . ConfigShowCommand::INPUT_OPTION_SCOPE_CODE ] = $ scopeCode ;
88
+ }
89
+
90
+ $ this ->commandTester ->execute ($ arguments );
99
91
100
92
$ this ->assertEquals (
101
93
Cli::RETURN_SUCCESS ,
102
94
$ this ->commandTester ->getStatusCode ()
103
95
);
104
- $ this ->assertContains (
105
- 'http://default.test/ ' ,
106
- $ this ->commandTester ->getDisplay ()
107
- );
108
- $ this ->assertContains (
109
- 'someValue ' ,
110
- $ this ->commandTester ->getDisplay ()
111
- );
96
+
97
+ foreach ($ configs as $ configPath => $ configValue ) {
98
+ $ this ->assertContains (
99
+ sprintf ("%s - %s " , $ configPath , $ configValue ),
100
+ $ this ->commandTester ->getDisplay ()
101
+ );
102
+ }
112
103
}
113
104
114
- public function testExecuteDataProvider ()
105
+ /**
106
+ * @return array
107
+ */
108
+ public function executeDataProvider ()
115
109
{
116
110
return [
117
111
[
@@ -120,7 +114,7 @@ public function testExecuteDataProvider()
120
114
[
121
115
'web/test/test_value_1 ' => 'http://default.test/ ' ,
122
116
'web/test/test_value_2 ' => 'someValue ' ,
123
- 'web/test/test_value_3 ' => 100 ,
117
+ 'web/test/test_value_3 ' => ' 100 ' ,
124
118
]
125
119
],
126
120
[
@@ -129,7 +123,7 @@ public function testExecuteDataProvider()
129
123
[
130
124
'web/test/test_value_1 ' => 'http://website.test/ ' ,
131
125
'web/test/test_value_2 ' => 'someWebsiteValue ' ,
132
- 'web/test/test_value_3 ' => 101 ,
126
+ 'web/test/test_value_3 ' => ' 101 ' ,
133
127
]
134
128
]
135
129
];
0 commit comments