Skip to content

Commit 1f442ce

Browse files
MAGETWO-65085: [PR] Delivery of deployment improvements
1 parent ac4b29a commit 1f442ce

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ConfigImportCommandTest.php

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ class ConfigImportCommandTest extends \PHPUnit_Framework_TestCase
5050
/**
5151
* @var array
5252
*/
53-
private $contentEnvFile = [];
53+
private $envConfig;
54+
55+
/**
56+
* @var array
57+
*/
58+
private $config;
5459

5560
protected function setUp()
5661
{
@@ -69,71 +74,69 @@ protected function setUp()
6974
$this->filesystem = $this->objectManager->get(Filesystem::class);
7075
$this->configFilePool = $this->objectManager->get(ConfigFilePool::class);
7176

72-
$this->contentEnvFile = $this->getEnvFileContent();
77+
$this->envConfig = $this->loadEnvConfig();
78+
$this->config = $this->loadConfig();
7379
}
7480

7581
public function tearDown()
7682
{
77-
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->delete(
78-
$this->getFileName()
83+
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile(
84+
$this->configFilePool->getPath(ConfigFilePool::APP_CONFIG),
85+
"<?php\n return array();\n"
7986
);
87+
/** @var DeploymentConfig\Writer $writer */
88+
$writer = $this->objectManager->get(DeploymentConfig\Writer::class);
89+
$writer->saveConfig([ConfigFilePool::APP_CONFIG => $this->config]);
90+
8091
$this->filesystem = $this->objectManager->get(Filesystem::class);
8192
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile(
8293
$this->configFilePool->getPath(ConfigFilePool::APP_ENV),
8394
"<?php\n return array();\n"
8495
);
85-
$this->writer->saveConfig([ConfigFilePool::APP_ENV => $this->contentEnvFile]);
96+
$this->writer->saveConfig([ConfigFilePool::APP_ENV => $this->envConfig]);
8697
}
8798

8899
public function testExecuteNothingImport()
89100
{
90-
$this->assertArrayNotHasKey(Hash::CONFIG_KEY, $this->contentEnvFile);
101+
$this->assertArrayNotHasKey(Hash::CONFIG_KEY, $this->envConfig);
91102
$command = $this->objectManager->create(ConfigImportCommand::class);
92103
$commandTester = new CommandTester($command);
93104
$commandTester->execute([]);
94105
$this->assertSame(Cli::RETURN_SUCCESS, $commandTester->getStatusCode());
95106
$this->assertContains('Start import', $commandTester->getDisplay());
96107
$this->assertContains('Nothing to import', $commandTester->getDisplay());
97-
$this->assertArrayNotHasKey(Hash::CONFIG_KEY, $this->getEnvFileContent());
108+
$this->assertArrayNotHasKey(Hash::CONFIG_KEY, $this->loadEnvConfig());
98109
}
99110

100111
public function testExecuteWithImport()
101112
{
102-
$this->assertArrayNotHasKey(Hash::CONFIG_KEY, $this->contentEnvFile);
113+
$this->assertArrayNotHasKey(Hash::CONFIG_KEY, $this->envConfig);
103114
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile(
104-
$this->getFileName(),
105-
file_get_contents(__DIR__ . '/../../../_files/_config.local.php')
115+
$this->configFilePool->getPath(ConfigFilePool::APP_CONFIG),
116+
file_get_contents(__DIR__ . '/../../../_files/config.php')
106117
);
107118
$command = $this->objectManager->create(ConfigImportCommand::class);
108119
$commandTester = new CommandTester($command);
109120
$commandTester->execute([]);
110121
$this->assertSame(Cli::RETURN_SUCCESS, $commandTester->getStatusCode());
111122
$this->assertContains('Start import', $commandTester->getDisplay());
112123
$this->assertContains('Integration test data is imported!', $commandTester->getDisplay());
113-
$this->assertArrayHasKey(Hash::CONFIG_KEY, $this->getEnvFileContent());
124+
$this->assertArrayHasKey(Hash::CONFIG_KEY, $this->loadEnvConfig());
114125
}
115126

116127
/**
117128
* @return array
118129
*/
119-
private function getEnvFileContent()
130+
private function loadConfig()
120131
{
121-
return $this->reader->loadConfigFile(
122-
ConfigFilePool::APP_ENV,
123-
$this->configFilePool->getPath(ConfigFilePool::APP_ENV),
124-
true
125-
);
132+
return $this->reader->load(ConfigFilePool::APP_CONFIG);
126133
}
127134

128135
/**
129-
* @return string
136+
* @return array
130137
*/
131-
private function getFileName()
138+
private function loadEnvConfig()
132139
{
133-
/** @var ConfigFilePool $configFilePool */
134-
$configFilePool = $this->objectManager->get(ConfigFilePool::class);
135-
$filePool = $configFilePool->getInitialFilePools();
136-
137-
return $filePool[ConfigFilePool::LOCAL][ConfigFilePool::APP_CONFIG];
140+
return $this->reader->load(ConfigFilePool::APP_ENV);
138141
}
139142
}

0 commit comments

Comments
 (0)