Skip to content

Commit e0ddb85

Browse files
author
Bohdan Korablov
committed
MAGETWO-63382: CLI Improvements: Configuration management - Command config:show
1 parent aba6e1f commit e0ddb85

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

dev/tests/integration/testsuite/Magento/Config/Console/Command/ConfigShowCommandTest.php

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Config\Console\Command;
77

8-
use Magento\Config\Console\Command\ConfigShow\ConfigSourceAggregated;
9-
use Magento\Framework\App\Config\ScopePathResolver;
108
use Magento\Store\Model\ScopeInterface;
119
use Magento\TestFramework\Helper\Bootstrap;
1210
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -22,26 +20,13 @@ class ConfigShowCommandTest extends \PHPUnit_Framework_TestCase
2220
private $objectManager;
2321

2422
/**
25-
* @var ConfigSourceAggregated
26-
*/
27-
private $config;
28-
29-
/**
30-
* @var CommandTester
31-
*/
23+
* @var CommandTester
24+
*/
3225
private $commandTester;
3326

34-
/**
35-
* @var ScopePathResolver
36-
*/
37-
private $pathResolver;
38-
3927
public function setUp()
4028
{
4129
$this->objectManager = Bootstrap::getObjectManager();
42-
$this->config = $this->objectManager->get(ConfigSourceAggregated::class);
43-
$this->pathResolver = $this->objectManager->get(ScopePathResolver::class);
44-
4530
$command = $this->objectManager->create(ConfigShowCommand::class);
4631
$this->commandTester = new CommandTester($command);
4732
}
@@ -52,7 +37,7 @@ public function setUp()
5237
* @param array $configs
5338
* @magentoDbIsolation enabled
5439
* @magentoDataFixture Magento/Config/_files/config_data.php
55-
* @dataProvider testExecuteDataProvider
40+
* @dataProvider executeDataProvider
5641
*/
5742
public function testExecute($scope, $scopeCode, array $configs)
5843
{
@@ -70,48 +55,57 @@ public function testExecute($scope, $scopeCode, array $configs)
7055

7156
$this->commandTester->execute($arguments);
7257

73-
$configPath = $this->pathResolver->resolve($inputPath, $scope, $scopeCode);
74-
$appConfigValue = $this->config->get($configPath);
7558
$this->assertEquals(
7659
Cli::RETURN_SUCCESS,
7760
$this->commandTester->getStatusCode()
7861
);
79-
$this->assertEquals(
80-
$configValue,
81-
$appConfigValue
82-
);
8362
$this->assertContains(
84-
$appConfigValue,
63+
$configValue,
8564
$this->commandTester->getDisplay()
8665
);
8766
}
8867
}
8968

9069
/**
70+
* @param string $scope
71+
* @param string $scopeCode
72+
* @param array $configs
9173
* @magentoDbIsolation enabled
9274
* @magentoDataFixture Magento/Config/_files/config_data.php
75+
* @dataProvider executeDataProvider
9376
*/
94-
public function testExecuteConfigGroup()
77+
public function testExecuteConfigGroup($scope, $scopeCode, array $configs)
9578
{
96-
$this->commandTester->execute([
79+
$arguments = [
9780
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);
9991

10092
$this->assertEquals(
10193
Cli::RETURN_SUCCESS,
10294
$this->commandTester->getStatusCode()
10395
);
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+
}
112103
}
113104

114-
public function testExecuteDataProvider()
105+
/**
106+
* @return array
107+
*/
108+
public function executeDataProvider()
115109
{
116110
return [
117111
[
@@ -120,7 +114,7 @@ public function testExecuteDataProvider()
120114
[
121115
'web/test/test_value_1' => 'http://default.test/',
122116
'web/test/test_value_2' => 'someValue',
123-
'web/test/test_value_3' => 100,
117+
'web/test/test_value_3' => '100',
124118
]
125119
],
126120
[
@@ -129,7 +123,7 @@ public function testExecuteDataProvider()
129123
[
130124
'web/test/test_value_1' => 'http://website.test/',
131125
'web/test/test_value_2' => 'someWebsiteValue',
132-
'web/test/test_value_3' => 101,
126+
'web/test/test_value_3' => '101',
133127
]
134128
]
135129
];

0 commit comments

Comments
 (0)