@@ -50,7 +50,12 @@ class ConfigImportCommandTest extends \PHPUnit_Framework_TestCase
50
50
/**
51
51
* @var array
52
52
*/
53
- private $ contentEnvFile = [];
53
+ private $ envConfig ;
54
+
55
+ /**
56
+ * @var array
57
+ */
58
+ private $ config ;
54
59
55
60
protected function setUp ()
56
61
{
@@ -69,71 +74,69 @@ protected function setUp()
69
74
$ this ->filesystem = $ this ->objectManager ->get (Filesystem::class);
70
75
$ this ->configFilePool = $ this ->objectManager ->get (ConfigFilePool::class);
71
76
72
- $ this ->contentEnvFile = $ this ->getEnvFileContent ();
77
+ $ this ->envConfig = $ this ->loadEnvConfig ();
78
+ $ this ->config = $ this ->loadConfig ();
73
79
}
74
80
75
81
public function tearDown ()
76
82
{
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"
79
86
);
87
+ /** @var DeploymentConfig\Writer $writer */
88
+ $ writer = $ this ->objectManager ->get (DeploymentConfig \Writer::class);
89
+ $ writer ->saveConfig ([ConfigFilePool::APP_CONFIG => $ this ->config ]);
90
+
80
91
$ this ->filesystem = $ this ->objectManager ->get (Filesystem::class);
81
92
$ this ->filesystem ->getDirectoryWrite (DirectoryList::CONFIG )->writeFile (
82
93
$ this ->configFilePool ->getPath (ConfigFilePool::APP_ENV ),
83
94
"<?php \n return array(); \n"
84
95
);
85
- $ this ->writer ->saveConfig ([ConfigFilePool::APP_ENV => $ this ->contentEnvFile ]);
96
+ $ this ->writer ->saveConfig ([ConfigFilePool::APP_ENV => $ this ->envConfig ]);
86
97
}
87
98
88
99
public function testExecuteNothingImport ()
89
100
{
90
- $ this ->assertArrayNotHasKey (Hash::CONFIG_KEY , $ this ->contentEnvFile );
101
+ $ this ->assertArrayNotHasKey (Hash::CONFIG_KEY , $ this ->envConfig );
91
102
$ command = $ this ->objectManager ->create (ConfigImportCommand::class);
92
103
$ commandTester = new CommandTester ($ command );
93
104
$ commandTester ->execute ([]);
94
105
$ this ->assertSame (Cli::RETURN_SUCCESS , $ commandTester ->getStatusCode ());
95
106
$ this ->assertContains ('Start import ' , $ commandTester ->getDisplay ());
96
107
$ this ->assertContains ('Nothing to import ' , $ commandTester ->getDisplay ());
97
- $ this ->assertArrayNotHasKey (Hash::CONFIG_KEY , $ this ->getEnvFileContent ());
108
+ $ this ->assertArrayNotHasKey (Hash::CONFIG_KEY , $ this ->loadEnvConfig ());
98
109
}
99
110
100
111
public function testExecuteWithImport ()
101
112
{
102
- $ this ->assertArrayNotHasKey (Hash::CONFIG_KEY , $ this ->contentEnvFile );
113
+ $ this ->assertArrayNotHasKey (Hash::CONFIG_KEY , $ this ->envConfig );
103
114
$ 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 ' )
106
117
);
107
118
$ command = $ this ->objectManager ->create (ConfigImportCommand::class);
108
119
$ commandTester = new CommandTester ($ command );
109
120
$ commandTester ->execute ([]);
110
121
$ this ->assertSame (Cli::RETURN_SUCCESS , $ commandTester ->getStatusCode ());
111
122
$ this ->assertContains ('Start import ' , $ commandTester ->getDisplay ());
112
123
$ 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 ());
114
125
}
115
126
116
127
/**
117
128
* @return array
118
129
*/
119
- private function getEnvFileContent ()
130
+ private function loadConfig ()
120
131
{
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 );
126
133
}
127
134
128
135
/**
129
- * @return string
136
+ * @return array
130
137
*/
131
- private function getFileName ()
138
+ private function loadEnvConfig ()
132
139
{
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 );
138
141
}
139
142
}
0 commit comments