Skip to content

Commit df382a3

Browse files
committed
[tests] handle missing type config value for doctrine
1 parent 716eee9 commit df382a3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/Maker/MakeEntityTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ private function createMakeEntityTest(bool $withDatabase = true): MakerTestDetai
3030
{
3131
return $this->createMakerTest()
3232
->preRun(function (MakerTestRunner $runner) use ($withDatabase) {
33-
if ($this->useAttributes($runner)) {
33+
$config = $runner->readYaml('config/packages/doctrine.yaml');
34+
35+
if (isset($config['doctrine']['orm']['mappings']['App']['type']) && $this->useAttributes($runner)) {
3436
// use attributes
3537
$runner->replaceInFile(
3638
'config/packages/doctrine.yaml',
@@ -656,13 +658,14 @@ private function setupGroupEntityInVendor(MakerTestRunner $runner)
656658
);
657659
}
658660

659-
private function changeToXmlMapping(MakerTestRunner $runner)
661+
private function changeToXmlMapping(MakerTestRunner $runner): void
660662
{
661-
$runner->replaceInFile(
662-
'config/packages/doctrine.yaml',
663-
$this->useAttributes($runner) ? 'type: attribute' : 'type: annotation',
664-
'type: xml'
665-
);
663+
$runner->modifyYamlFile('config/packages/doctrine.yaml', function (array $data) {
664+
$data['doctrine']['orm']['mappings']['App']['type'] = 'xml';
665+
666+
return $data;
667+
});
668+
666669
$runner->replaceInFile(
667670
'config/packages/doctrine.yaml',
668671
"dir: '%kernel.project_dir%/src/Entity'",

0 commit comments

Comments
 (0)