2323use Symfony \Flex \Update \RecipeUpdate ;
2424
2525/**
26- * @author Kévin Dunglas <[email protected] > 26+ * @author Kévin Dunglas <[email protected] > 2727 */
2828class DockerComposeConfiguratorTest extends TestCase
2929{
@@ -166,18 +166,33 @@ protected function tearDown(): void
166166 putenv ('COMPOSER= ' .$ this ->originalEnvComposer );
167167
168168 (new Filesystem ())->remove ([
169+ FLEX_TEST_DIR .'/compose.yml ' ,
169170 FLEX_TEST_DIR .'/docker-compose.yml ' ,
171+ FLEX_TEST_DIR .'/compose.override.yml ' ,
170172 FLEX_TEST_DIR .'/docker-compose.override.yml ' ,
173+ FLEX_TEST_DIR .'/compose.yaml ' ,
171174 FLEX_TEST_DIR .'/docker-compose.yaml ' ,
172175 FLEX_TEST_DIR .'/composer.json ' ,
176+ FLEX_TEST_DIR .'/child/compose.override.yaml ' ,
173177 FLEX_TEST_DIR .'/child/docker-compose.override.yaml ' ,
174178 FLEX_TEST_DIR .'/child ' ,
175179 ]);
176180 }
177181
178- public function testConfigure ()
182+ public static function dockerComposerFileProvider (): iterable
179183 {
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 " ;
181196 file_put_contents ($ dockerComposeFile , self ::ORIGINAL_CONTENT );
182197
183198 $ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
@@ -205,7 +220,7 @@ public function testConfigure()
205220###< doctrine/doctrine-bundle ###
206221
207222YAML
208- );
223+ );
209224
210225 $ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
211226 $ this ->assertEquals (self ::ORIGINAL_CONTENT , file_get_contents ($ dockerComposeFile ));
@@ -216,7 +231,7 @@ public function testNotConfiguredIfConfigSet()
216231 $ this ->package ->setExtra (['symfony ' => ['docker ' => false ]]);
217232 $ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
218233
219- $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/docker-compose.yml ' );
234+ $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/docker-compose.yaml ' );
220235 }
221236
222237 /**
@@ -235,9 +250,9 @@ public function testPreferenceAskedInteractively(string $userInput, bool $expect
235250 $ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
236251
237252 if ($ expectedIsConfigured ) {
238- $ this ->assertFileExists (FLEX_TEST_DIR .'/docker- compose.yml ' );
253+ $ this ->assertFileExists (FLEX_TEST_DIR .'/compose.yaml ' );
239254 } else {
240- $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/docker- compose.yml ' );
255+ $ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/compose.yaml ' );
241256 }
242257
243258 $ composerJsonData = json_decode (file_get_contents ($ composerJsonPath ), true );
@@ -270,7 +285,7 @@ public function testEnvVarUsedForDockerConfirmation()
270285 $ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
271286 unset($ _SERVER ['SYMFONY_DOCKER ' ]);
272287
273- $ this ->assertFileExists (FLEX_TEST_DIR .'/docker- compose.yml ' );
288+ $ this ->assertFileExists (FLEX_TEST_DIR .'/compose.yaml ' );
274289
275290 $ composerJsonData = json_decode (file_get_contents ($ composerJsonPath ), true );
276291 $ this ->assertArrayHasKey ('extra ' , $ composerJsonData );
@@ -316,7 +331,7 @@ public function testConfigureFileWithExistingVolumes()
316331###< doctrine/doctrine-bundle ###
317332
318333YAML
319- );
334+ );
320335
321336 $ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
322337 // Not the same original, we have an extra breaks line
@@ -411,7 +426,7 @@ public function testConfigureFileWithExistingMarks()
411426###< doctrine/doctrine-bundle ###
412427
413428YAML
414- );
429+ );
415430
416431 $ this ->configurator ->unconfigure ($ recipe , $ config , $ this ->lock );
417432 $ this ->assertEquals ($ originalContent , file_get_contents ($ dockerComposeFile ));
@@ -526,7 +541,7 @@ public function testConfigureMultipleFiles()
526541###< doctrine/doctrine-bundle ###
527542
528543YAML
529- );
544+ );
530545 }
531546
532547 $ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB_MULTIPLE_FILES , $ this ->lock );
@@ -571,7 +586,7 @@ public function testConfigureEnvVar()
571586###< doctrine/doctrine-bundle ###
572587
573588YAML
574- );
589+ );
575590 }
576591
577592 $ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB_MULTIPLE_FILES , $ this ->lock );
@@ -624,7 +639,7 @@ public function testConfigureFileInParentDir()
624639
625640 public function testConfigureWithoutExistingDockerComposeFiles ()
626641 {
627- $ dockerComposeFile = FLEX_TEST_DIR .'/docker- compose.yml ' ;
642+ $ dockerComposeFile = FLEX_TEST_DIR .'/compose.yaml ' ;
628643 $ defaultContent = "version: '3' \n" ;
629644
630645 $ this ->configurator ->configure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
@@ -653,7 +668,7 @@ public function testConfigureWithoutExistingDockerComposeFiles()
653668###< doctrine/doctrine-bundle ###
654669
655670YAML
656- );
671+ );
657672
658673 $ this ->configurator ->unconfigure ($ this ->recipeDb , self ::CONFIG_DB , $ this ->lock );
659674 $ this ->assertEquals (trim ($ defaultContent ), file_get_contents ($ dockerComposeFile ));
0 commit comments