3737use Symfony \Component \VarExporter \LazyGhostTrait ;
3838
3939use function assert ;
40+ use function class_exists ;
4041use function interface_exists ;
4142use function sys_get_temp_dir ;
4243use function trait_exists ;
4344
45+ use const PHP_VERSION_ID ;
46+
4447class DoctrineMigrationsExtensionTest extends TestCase
4548{
4649 use ExpectDeprecationTrait;
@@ -290,7 +293,8 @@ public function testPrefersEntityManagerOverConnection(): void
290293 $ config = [
291294 'migrations_paths ' => ['DoctrineMigrationsTest ' => 'a ' ],
292295 ];
293- $ ormConfig = trait_exists (LazyGhostTrait::class) ? ['enable_lazy_ghost_objects ' => true ] : [];
296+ $ ormConfig = PHP_VERSION_ID < 80400 && trait_exists (LazyGhostTrait::class) && class_exists (CacheCompatibilityPass::class)
297+ ? ['enable_lazy_ghost_objects ' => true ] : [];
294298 if (InstalledVersions::satisfies (new VersionParser (), 'doctrine/doctrine-bundle ' , '^2.7.1 ' )) {
295299 $ ormConfig ['controller_resolver ' ] = ['auto_mapping ' => false ];
296300 }
@@ -363,7 +367,7 @@ public function testCustomEntityManager(): void
363367 $ ormConfig ['controller_resolver ' ] = ['auto_mapping ' => false ];
364368 }
365369
366- if (trait_exists (LazyGhostTrait::class)) {
370+ if (PHP_VERSION_ID < 80400 && trait_exists (LazyGhostTrait::class) && class_exists (CacheCompatibilityPass ::class)) {
367371 $ ormConfig ['enable_lazy_ghost_objects ' ] = true ;
368372 }
369373
@@ -466,6 +470,7 @@ public function testTransactionalSetToFalseReflectsInConfig(): void
466470 private function getContainer (array $ config , ?array $ dbalConfig = null , ?array $ ormConfig = null ): ContainerBuilder
467471 {
468472 $ container = $ this ->getContainerBuilder ();
473+ $ container ->setParameter ('kernel.build_dir ' , '' );
469474
470475 $ bundle = new DoctrineMigrationsBundle ();
471476 $ bundle ->build ($ container );
@@ -488,7 +493,10 @@ private function getContainer(array $config, ?array $dbalConfig = null, ?array $
488493 $ container ->getDefinition ('doctrine_migrations.schema_filter_listener ' )->setPublic (true );
489494 }
490495
491- $ container ->addCompilerPass (new CacheCompatibilityPass ());
496+ if (class_exists (CacheCompatibilityPass::class)) {
497+ /** @phpstan-ignore argument.type */
498+ $ container ->addCompilerPass (new CacheCompatibilityPass ());
499+ }
492500
493501 return $ container ;
494502 }
0 commit comments