17 use Symfony\Component\Console\Input\InputInterface;
18 use Symfony\Component\Console\Output\OutputInterface;
23 class ApplicationDumpCommandTest
extends \PHPUnit\Framework\TestCase
38 private $configFilePool;
68 public function setUp()
71 $this->reader = $this->objectManager->get(
DeploymentConfig\FileReader::class);
72 $this->filesystem = $this->objectManager->get(Filesystem::class);
73 $this->configFilePool = $this->objectManager->get(ConfigFilePool::class);
76 $this->configFilePool = $this->objectManager->get(ConfigFilePool::class);
77 $this->hash = $this->objectManager->get(Hash::class);
80 $this->config = $this->loadConfig();
81 $this->envConfig = $this->loadEnvConfig();
83 $this->writer->saveConfig(
90 'test_value_3' =>
'value from the file' 104 private function loadConfig()
112 private function loadEnvConfig()
120 private function loadRawConfig()
130 public function testExecute()
132 $this->objectManager->configure([
133 ExcludeList::class => [
136 'web/test/test_value_1' =>
'',
137 'web/test/test_value_2' =>
'0',
138 'web/test/test_sensitive' =>
'1',
145 'web/test/test_sensitive1' =>
'',
146 'web/test/test_sensitive2' =>
'0',
147 'web/test/test_sensitive3' =>
'1',
148 'web/test/test_sensitive_environment4' =>
'1',
149 'web/test/test_sensitive_environment5' =>
'1',
150 'web/test/test_sensitive_environment6' =>
'0',
153 'web/test/test_sensitive_environment4' =>
'1',
154 'web/test/test_sensitive_environment5' =>
'0',
155 'web/test/test_sensitive_environment6' =>
'1',
156 'web/test/test_environment7' =>
'',
157 'web/test/test_environment8' =>
'0',
158 'web/test/test_environment9' =>
'1',
164 $comment = implode(PHP_EOL, [
165 'Shared configuration was written to config.php and system-specific configuration to env.php.',
166 'Shared configuration file (config.php) doesn\'t contain sensitive data for security reasons.',
167 'Sensitive data can be stored in the following environment variables:',
168 'CONFIG__DEFAULT__WEB__TEST__TEST_SENSITIVE for web/test/test_sensitive',
169 'CONFIG__DEFAULT__WEB__TEST__TEST_SENSITIVE3 for web/test/test_sensitive3',
170 'CONFIG__DEFAULT__WEB__TEST__TEST_SENSITIVE_ENVIRONMENT4 for web/test/test_sensitive_environment4',
171 'CONFIG__DEFAULT__WEB__TEST__TEST_SENSITIVE_ENVIRONMENT5 for web/test/test_sensitive_environment5' 173 $outputMock = $this->createMock(OutputInterface::class);
174 $outputMock->expects($this->at(0))
176 ->with([
'system' => $comment]);
177 $outputMock->expects($this->at(1))
179 ->with($this->matchesRegularExpression(
'/<info>Done. Config types dumped: [a-z0-9,\s]+<\/info>/'));
182 $command = $this->objectManager->create(ApplicationDumpCommand::class);
183 $command->run($this->createMock(InputInterface::class), $outputMock);
187 $this->validateSystemSection(
$config);
188 $this->validateThemesSection(
$config);
190 $configEnv = $this->loadEnvConfig();
191 $this->validateSystemEnvSection($configEnv);
193 $this->assertNotEmpty($this->hash->get());
194 $this->assertContains(
'For the section: system', $this->loadRawConfig());
203 private function validateSystemSection(array
$config)
205 $this->assertArrayHasKey(
'test_value_1',
$config[
'system'][
'default'][
'web'][
'test']);
206 $this->assertArrayHasKey(
'test_value_2',
$config[
'system'][
'default'][
'web'][
'test']);
207 $this->assertArrayHasKey(
'test_sensitive1',
$config[
'system'][
'default'][
'web'][
'test']);
208 $this->assertArrayHasKey(
'test_sensitive2',
$config[
'system'][
'default'][
'web'][
'test']);
209 $this->assertArrayHasKey(
'test_environment7',
$config[
'system'][
'default'][
'web'][
'test']);
210 $this->assertArrayHasKey(
'test_environment8',
$config[
'system'][
'default'][
'web'][
'test']);
211 $this->assertArrayNotHasKey(
'test_sensitive',
$config[
'system'][
'default'][
'web'][
'test']);
212 $this->assertArrayNotHasKey(
'test_sensitive3',
$config[
'system'][
'default'][
'web'][
'test']);
213 $this->assertArrayNotHasKey(
'test_sensitive_environment4',
$config[
'system'][
'default'][
'web'][
'test']);
214 $this->assertArrayNotHasKey(
'test_sensitive_environment5',
$config[
'system'][
'default'][
'web'][
'test']);
215 $this->assertArrayNotHasKey(
'test_sensitive_environment6',
$config[
'system'][
'default'][
'web'][
'test']);
216 $this->assertArrayNotHasKey(
'test_environment9',
$config[
'system'][
'default'][
'web'][
'test']);
219 'frontend/Magento/blank',
220 $config[
'system'][
'default'][
'design'][
'theme'][
'theme_id']
223 'frontend/Magento/luma',
224 $config[
'system'][
'stores'][
'default'][
'design'][
'theme'][
'theme_id']
227 'frontend/Magento/luma',
228 $config[
'system'][
'websites'][
'base'][
'design'][
'theme'][
'theme_id']
231 $this->assertEquals(
'value from the file',
$config[
'system'][
'default'][
'web'][
'test'][
'test_value_3']);
232 $this->assertEquals(
'GB',
$config[
'system'][
'default'][
'general'][
'country'][
'default']);
235 $config[
'system'][
'default'][
'general'][
'country'][
'optional_zip_countries']
245 private function validateSystemEnvSection(array
$config)
250 'test_sensitive_environment4',
251 'test_sensitive_environment5',
252 'test_sensitive_environment6',
257 array_diff($envTestKeys, array_keys(
$config[
'system'][
'default'][
'web'][
'test']))
267 private function validateThemesSection(array
$config)
272 'theme_path' =>
'Magento/backend',
273 'theme_title' =>
'Magento 2 backend',
274 'is_featured' =>
'0',
275 'area' =>
'adminhtml',
277 'code' =>
'Magento/backend',
279 $config[
'themes'][
'adminhtml/Magento/backend']
284 'theme_path' =>
'Magento/blank',
285 'theme_title' =>
'Magento Blank',
286 'is_featured' =>
'0',
287 'area' =>
'frontend',
289 'code' =>
'Magento/blank',
291 $config[
'themes'][
'frontend/Magento/blank']
295 'parent_id' =>
'Magento/blank',
296 'theme_path' =>
'Magento/luma',
297 'theme_title' =>
'Magento Luma',
298 'is_featured' =>
'0',
299 'area' =>
'frontend',
301 'code' =>
'Magento/luma',
303 $config[
'themes'][
'frontend/Magento/luma']
310 public function tearDown()
314 "<?php\n return array();\n" 318 "<?php\n return array();\n" 322 $writer = $this->objectManager->get(DeploymentConfig\Writer::class);
326 $writer = $this->objectManager->get(DeploymentConfig\Writer::class);
static getObjectManager()