23
23
use Symfony \Flex \Update \RecipeUpdate ;
24
24
25
25
/**
26
- * @author Kévin Dunglas <[email protected] >
26
+ * @author Kévin Dunglas <[email protected] >
27
27
*/
28
28
class DockerComposeConfiguratorTest extends TestCase
29
29
{
@@ -166,18 +166,33 @@ protected function tearDown(): void
166
166
putenv ('COMPOSER= ' .$ this ->originalEnvComposer );
167
167
168
168
(new Filesystem ())->remove ([
169
+ FLEX_TEST_DIR .'/compose.yml ' ,
169
170
FLEX_TEST_DIR .'/docker-compose.yml ' ,
171
+ FLEX_TEST_DIR .'/compose.override.yml ' ,
170
172
FLEX_TEST_DIR .'/docker-compose.override.yml ' ,
173
+ FLEX_TEST_DIR .'/compose.yaml ' ,
171
174
FLEX_TEST_DIR .'/docker-compose.yaml ' ,
172
175
FLEX_TEST_DIR .'/composer.json ' ,
176
+ FLEX_TEST_DIR .'/child/compose.override.yaml ' ,
173
177
FLEX_TEST_DIR .'/child/docker-compose.override.yaml ' ,
174
178
FLEX_TEST_DIR .'/child ' ,
175
179
]);
176
180
}
177
181
178
- public function testConfigure ()
182
+ public static function dockerComposerFileProvider (): iterable
179
183
{
180
- $ dockerComposeFile = FLEX_TEST_DIR .'/docker-compose.yaml ' ;
184
+ yield ['compose.yaml ' ];
185
+ yield ['compose.yml ' ];
186
+ yield ['docker-compose.yaml ' ];
187
+ yield ['docker-compose.yml ' ];
188
+ }
189
+
190
+ /**
191
+ * @dataProvider dockerComposerFileProvider
192
+ */
193
+ public function testConfigure (string $ fileName )
194
+ {
195
+ $ dockerComposeFile = FLEX_TEST_DIR ."/ $ fileName " ;
181
196
file_put_contents ($ dockerComposeFile , self ::ORIGINAL_CONTENT );
182
197
183
198
$ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
@@ -205,7 +220,7 @@ public function testConfigure()
205
220
###< doctrine/doctrine-bundle ###
206
221
207
222
YAML
208
- );
223
+ );
209
224
210
225
$ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
211
226
$ this ->assertEquals (self ::ORIGINAL_CONTENT , file_get_contents ($ dockerComposeFile ));
@@ -216,7 +231,7 @@ public function testNotConfiguredIfConfigSet()
216
231
$ this ->package ->setExtra (['symfony ' => ['docker ' => false ]]);
217
232
$ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
218
233
219
- $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/docker-compose.yml ' );
234
+ $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/docker-compose.yaml ' );
220
235
}
221
236
222
237
/**
@@ -235,9 +250,9 @@ public function testPreferenceAskedInteractively(string $userInput, bool $expect
235
250
$ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
236
251
237
252
if ($ expectedIsConfigured ) {
238
- $ this ->assertFileExists (FLEX_TEST_DIR .'/docker- compose.yml ' );
253
+ $ this ->assertFileExists (FLEX_TEST_DIR .'/compose.yaml ' );
239
254
} else {
240
- $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/docker- compose.yml ' );
255
+ $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/compose.yaml ' );
241
256
}
242
257
243
258
$ composerJsonData = json_decode (file_get_contents ($ composerJsonPath ), true );
@@ -270,7 +285,7 @@ public function testEnvVarUsedForDockerConfirmation()
270
285
$ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
271
286
unset($ _SERVER ['SYMFONY_DOCKER ' ]);
272
287
273
- $ this ->assertFileExists (FLEX_TEST_DIR .'/docker- compose.yml ' );
288
+ $ this ->assertFileExists (FLEX_TEST_DIR .'/compose.yaml ' );
274
289
275
290
$ composerJsonData = json_decode (file_get_contents ($ composerJsonPath ), true );
276
291
$ this ->assertArrayHasKey ('extra ' , $ composerJsonData );
@@ -316,7 +331,7 @@ public function testConfigureFileWithExistingVolumes()
316
331
###< doctrine/doctrine-bundle ###
317
332
318
333
YAML
319
- );
334
+ );
320
335
321
336
$ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
322
337
// Not the same original, we have an extra breaks line
@@ -411,7 +426,7 @@ public function testConfigureFileWithExistingMarks()
411
426
###< doctrine/doctrine-bundle ###
412
427
413
428
YAML
414
- );
429
+ );
415
430
416
431
$ this ->configurator ->unconfigure ($ recipe , $ config , $ this ->lock );
417
432
$ this ->assertEquals ($ originalContent , file_get_contents ($ dockerComposeFile ));
@@ -526,7 +541,7 @@ public function testConfigureMultipleFiles()
526
541
###< doctrine/doctrine-bundle ###
527
542
528
543
YAML
529
- );
544
+ );
530
545
}
531
546
532
547
$ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB_MULTIPLE_FILES , $ this ->lock );
@@ -571,7 +586,7 @@ public function testConfigureEnvVar()
571
586
###< doctrine/doctrine-bundle ###
572
587
573
588
YAML
574
- );
589
+ );
575
590
}
576
591
577
592
$ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB_MULTIPLE_FILES , $ this ->lock );
@@ -624,7 +639,7 @@ public function testConfigureFileInParentDir()
624
639
625
640
public function testConfigureWithoutExistingDockerComposeFiles ()
626
641
{
627
- $ dockerComposeFile = FLEX_TEST_DIR .'/docker- compose.yml ' ;
642
+ $ dockerComposeFile = FLEX_TEST_DIR .'/compose.yaml ' ;
628
643
$ defaultContent = "version: '3' \n" ;
629
644
630
645
$ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
@@ -653,7 +668,7 @@ public function testConfigureWithoutExistingDockerComposeFiles()
653
668
###< doctrine/doctrine-bundle ###
654
669
655
670
YAML
656
- );
671
+ );
657
672
658
673
$ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
659
674
$ this ->assertEquals (trim ($ defaultContent ), file_get_contents ($ dockerComposeFile ));
0 commit comments