|
41 | 41 | use function sys_get_temp_dir; |
42 | 42 | use function trait_exists; |
43 | 43 |
|
| 44 | +use const PHP_VERSION_ID; |
| 45 | + |
44 | 46 | class DoctrineMigrationsExtensionTest extends TestCase |
45 | 47 | { |
46 | 48 | use ExpectDeprecationTrait; |
@@ -287,10 +289,12 @@ public function testCustomConnection(): void |
287 | 289 |
|
288 | 290 | public function testPrefersEntityManagerOverConnection(): void |
289 | 291 | { |
290 | | - $config = [ |
| 292 | + $config = [ |
291 | 293 | 'migrations_paths' => ['DoctrineMigrationsTest' => 'a'], |
292 | 294 | ]; |
293 | | - $ormConfig = trait_exists(LazyGhostTrait::class) ? ['enable_lazy_ghost_objects' => true] : []; |
| 295 | + |
| 296 | + $ormConfig = PHP_VERSION_ID < 80400 && trait_exists(LazyGhostTrait::class) ? ['enable_lazy_ghost_objects' => true] : []; |
| 297 | + |
294 | 298 | if (InstalledVersions::satisfies(new VersionParser(), 'doctrine/doctrine-bundle', '^2.7.1 ')) { |
295 | 299 | $ormConfig['controller_resolver'] = ['auto_mapping' => false]; |
296 | 300 | } |
@@ -363,7 +367,12 @@ public function testCustomEntityManager(): void |
363 | 367 | $ormConfig['controller_resolver'] = ['auto_mapping' => false]; |
364 | 368 | } |
365 | 369 |
|
366 | | - if (trait_exists(LazyGhostTrait::class)) { |
| 370 | + if (PHP_VERSION_ID >= 80400) { |
| 371 | + foreach ($ormConfig['entity_managers'] as $name => $emConfig) { |
| 372 | + $ormConfig['entity_managers'][$name]['enable_native_lazy_objects'] = true; |
| 373 | + } |
| 374 | + } elseif (interface_exists(LazyGhostTrait::class)) { |
| 375 | + // For PHP 8.0 and 8.1 we need to check for the interface as the trait is only used when the interface exists |
367 | 376 | $ormConfig['enable_lazy_ghost_objects'] = true; |
368 | 377 | } |
369 | 378 |
|
@@ -506,6 +515,7 @@ private function getContainerBuilder(): ContainerBuilder |
506 | 515 | 'namespace' => $bundle->getNamespace(), |
507 | 516 | ], |
508 | 517 | ], |
| 518 | + 'kernel.build_dir' => sys_get_temp_dir(), |
509 | 519 | 'kernel.cache_dir' => sys_get_temp_dir(), |
510 | 520 | 'kernel.environment' => 'test', |
511 | 521 | 'kernel.project_dir' => __DIR__ . '/../', |
|
0 commit comments