2525use PHPUnit \Framework \Assert ;
2626use PHPUnit \Framework \Attributes \DataProvider ;
2727use PHPUnit \Framework \Attributes \Group ;
28+ use PHPUnit \Framework \Attributes \RequiresPhp ;
29+ use ReflectionClass ;
2830use ReflectionProperty ;
2931use stdClass ;
30- use Symfony \Component \VarExporter \LazyGhostTrait ;
3132use TypeError ;
3233
3334class EntityManagerTest extends OrmTestCase
@@ -180,17 +181,12 @@ public function testWrapInTransactionReThrowsThrowables(): void
180181 }
181182
182183 /** Resetting the EntityManager relies on lazy objects until https://github.com/doctrine/orm/issues/5933 is resolved */
184+ #[RequiresPhp('8.4 ' )]
183185 public function testLazyGhostEntityManager (): void
184186 {
185- $ em = new class () extends EntityManager {
186- use LazyGhostTrait;
187+ $ reflector = new ReflectionClass (EntityManager::class);
187188
188- public function __construct ()
189- {
190- }
191- };
192-
193- $ em = $ em ::createLazyGhost (static function ($ em ): void {
189+ $ em = $ reflector ->newLazyGhost ($ initializer = static function (EntityManager $ em ): void {
194190 $ r = new ReflectionProperty (EntityManager::class, 'unitOfWork ' );
195191 $ r ->setValue ($ em , new class () extends UnitOfWork {
196192 public function __construct ()
@@ -207,7 +203,7 @@ public function clear(): void
207203 $ em ->close ();
208204 $ this ->assertFalse ($ em ->isOpen ());
209205
210- $ em -> resetLazyObject ( );
206+ $ reflector -> resetAsLazyGhost ( $ em , $ initializer );
211207 $ this ->assertTrue ($ em ->isOpen ());
212208 }
213209
0 commit comments