Skip to content

Commit 64318ec

Browse files
committed
minor #1067 [ci] handle when@test for doctrine (jrushlow)
This PR was merged into the 1.0-dev branch. Discussion ---------- [ci] handle when@test for doctrine DoctrineBundle >= 2.4 Flex Recipe uses `when@test` in the `config/packages/doctrine.yaml` file instead of a separate `config/packages/test/doctrine.yaml` file. Prior to this PR we were removing the `test/doctrine.yaml` file because we did not want to use the `_test` database suffix in our tests. Now we remove the `dbname_suffix` property if it isset in the test environment. For BC, we still remove the `test/doctrine.yaml` file. We could remove then entire `when@test` property from `doctrine.yaml`, but it would probably be best to do this if something changes to the recipe in the future that warrants the removal. (Something may be added that we don't want to remove in the future as well.) Commits ------- 186825a [ci] handle when@test for doctrine
2 parents 73ecf23 + 186825a commit 64318ec

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Test/MakerTestRunner.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,21 @@ public function configureDatabase(bool $createSchema = true): void
178178

179179
// Flex includes a recipe to suffix the dbname w/ "_test" - lets keep
180180
// things simple for these tests and not do that.
181-
$this->removeFromFile(
182-
'config/packages/test/doctrine.yaml',
183-
"dbname_suffix: '_test%env(default::TEST_TOKEN)%'"
184-
);
181+
$this->modifyYamlFile('config/packages/doctrine.yaml', function (array $config) {
182+
if (isset($config['when@test']['doctrine']['dbal']['dbname_suffix'])) {
183+
unset($config['when@test']['doctrine']['dbal']['dbname_suffix']);
184+
}
185+
186+
return $config;
187+
});
188+
189+
// @legacy DoctrineBundle 2.4 recipe uses when@test instead of a test/doctrine.yaml config
190+
if ($this->filesystem->exists('config/packages/test/doctrine.yaml')) {
191+
$this->removeFromFile(
192+
'config/packages/test/doctrine.yaml',
193+
"dbname_suffix: '_test%env(default::TEST_TOKEN)%'"
194+
);
195+
}
185196

186197
// this looks silly, but it's the only way to drop the database *for sure*,
187198
// as doctrine:database:drop will error if there is no database

0 commit comments

Comments
 (0)