File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,24 @@ private function createMakeEntityTest(bool $withDatabase = true): MakerTestDetai
31
31
return $ this ->createMakerTest ()
32
32
->preRun (function (MakerTestRunner $ runner ) use ($ withDatabase ) {
33
33
$ config = $ runner ->readYaml ('config/packages/doctrine.yaml ' );
34
+ $ appMapping = $ config ['doctrine ' ]['orm ' ]['mappings ' ]['App ' ] ?? [];
34
35
35
- if (isset ($ config ['doctrine ' ]['orm ' ]['mappings ' ]['App ' ]['type ' ]) && $ this ->useAttributes ($ runner )) {
36
- // use attributes
36
+ /* @legacy Refactor when annotations are no longer supported. */
37
+ if (isset ($ appMapping ['type ' ]) && $ this ->useAttributes ($ runner )) {
38
+ // We want to use attributes by default in tests if they're supported.
37
39
$ runner ->replaceInFile (
38
40
'config/packages/doctrine.yaml ' ,
39
41
'type: annotation ' ,
40
42
'type: attribute '
41
43
);
44
+ } elseif (!empty ($ appMapping ) && !$ this ->useAttributes ($ runner )) {
45
+ // Flex assumes attributes are supported based on package versions.
46
+ // When PHP <8.0, we have to use annotations.
47
+ $ runner ->modifyYamlFile ('config/packages/doctrine.yaml ' , function (array $ data ) {
48
+ $ data ['doctrine ' ]['orm ' ]['mappings ' ]['App ' ]['type ' ] = 'annotation ' ;
49
+
50
+ return $ data ;
51
+ });
42
52
}
43
53
44
54
if ($ withDatabase ) {
You can’t perform that action at this time.
0 commit comments