@@ -178,31 +178,28 @@ public function testExecuteWithoutDbConfigInEnvironment()
178
178
179
179
/**
180
180
* Case when slave connections and split database are not used
181
+ *
182
+ * @param $mageConfig array
183
+ * @param $envConfig array
184
+ * @param $expectedResult array
185
+ * @dataProvider executeWithoutSplitAndSlaveConfigDataProvider
181
186
*/
182
- public function testExecuteWithoutSplitAndSlaveConfig ()
187
+ public function testExecuteWithoutSplitAndSlaveConfig (array $ mageConfig , array $ envConfig , array $ expectedResult )
183
188
{
184
189
$ resourceConfig = [
185
190
'default_setup ' => self ::RESOURCE_DEFAULT_SETUP ,
186
191
];
192
+ $ expectedResult ['resource ' ] = $ resourceConfig ;
187
193
188
- $ dbConfig = [
189
- 'connection ' => [
190
- 'default ' => self ::DEFAULT_CONNECTION ,
191
- 'indexer ' => self ::DEFAULT_CONNECTION ,
192
- ]
193
- ];
194
194
$ this ->dbConfigMock ->expects ($ this ->once ())
195
195
->method ('get ' )
196
- ->willReturn ($ dbConfig );
196
+ ->willReturn ($ envConfig );
197
197
$ this ->loggerMock ->expects ($ this ->once ())
198
198
->method ('info ' )
199
199
->with ('Updating env.php DB connection configuration. ' );
200
200
$ this ->configReaderMock ->expects ($ this ->once ())
201
201
->method ('read ' )
202
- ->willReturn ([
203
- 'db ' => $ dbConfig ,
204
- 'resource ' => $ resourceConfig
205
- ]);
202
+ ->willReturn ($ mageConfig );
206
203
$ this ->resourceConfigMock ->expects ($ this ->once ())
207
204
->method ('get ' )
208
205
->willReturn ($ resourceConfig );
@@ -212,16 +209,51 @@ public function testExecuteWithoutSplitAndSlaveConfig()
212
209
->willReturnOnConsecutiveCalls (false , []);
213
210
$ this ->configWriterMock ->expects ($ this ->once ())
214
211
->method ('create ' )
215
- ->with ([
216
- 'db ' => $ dbConfig ,
217
- 'resource ' => $ resourceConfig
218
- ]);
212
+ ->with ($ expectedResult );
219
213
$ this ->flagManagerMock ->expects ($ this ->never ())
220
214
->method ('set ' );
221
215
222
216
$ this ->step ->execute ();
223
217
}
224
218
219
+ /**
220
+ * @return array
221
+ */
222
+ public function executeWithoutSplitAndSlaveConfigDataProvider ()
223
+ {
224
+ $ dbConfig = [
225
+ 'connection ' => [
226
+ 'default ' => self ::DEFAULT_CONNECTION ,
227
+ 'indexer ' => self ::DEFAULT_CONNECTION ,
228
+ ]
229
+ ];
230
+ $ newConnection = array_merge (self ::DEFAULT_CONNECTION , ['host ' => 'host2 ' ]);
231
+ $ newBbConfig = [
232
+ 'connection ' => [
233
+ 'default ' => $ newConnection ,
234
+ 'indexer ' => $ newConnection ,
235
+ ]
236
+ ];
237
+
238
+ return [
239
+ [
240
+ ['db ' => $ dbConfig ],
241
+ $ dbConfig ,
242
+ ['db ' => $ dbConfig ],
243
+ ],
244
+ 'changed connection ' => [
245
+ ['db ' => $ dbConfig ],
246
+ $ newBbConfig ,
247
+ ['db ' => $ newBbConfig ],
248
+ ],
249
+ 'no data before ' => [
250
+ [],
251
+ $ dbConfig ,
252
+ ['db ' => $ dbConfig ],
253
+ ],
254
+ ];
255
+ }
256
+
225
257
/**
226
258
* Case with slave connections and without split config
227
259
*/
0 commit comments