1111
1212namespace Symfony \Bridge \Doctrine \Tests ;
1313
14+ use Doctrine \Persistence \ObjectManager ;
1415use PHPUnit \Framework \TestCase ;
1516use ProxyManager \Proxy \LazyLoadingInterface ;
1617use ProxyManager \Proxy \ValueHolderInterface ;
18+ use Symfony \Bridge \Doctrine \Tests \Fixtures \DummyManager ;
1719use Symfony \Bridge \ProxyManager \LazyProxy \PhpDumper \ProxyDumper ;
18- use Symfony \Bridge \ProxyManager \Tests \LazyProxy \Dumper \PhpDumperTest ;
1920use Symfony \Component \DependencyInjection \ContainerBuilder ;
2021use Symfony \Component \DependencyInjection \ContainerInterface ;
2122use Symfony \Component \DependencyInjection \Dumper \PhpDumper ;
@@ -28,9 +29,16 @@ class LegacyManagerRegistryTest extends TestCase
2829{
2930 public static function setUpBeforeClass (): void
3031 {
31- if (!class_exists (\LazyServiceProjectServiceContainer::class, false )) {
32- eval ('?> ' .PhpDumperTest::dumpLazyServiceProjectServiceContainer ());
33- }
32+ $ container = new ContainerBuilder ();
33+
34+ $ container ->register ('foo ' , DummyManager::class)->setPublic (true );
35+ $ container ->getDefinition ('foo ' )->setLazy (true )->addTag ('proxy ' , ['interface ' => ObjectManager::class]);
36+ $ container ->compile ();
37+
38+ $ dumper = new PhpDumper ($ container );
39+ $ dumper ->setProxyDumper (new ProxyDumper ());
40+
41+ eval ('?> ' .$ dumper ->dump (['class ' => 'LazyServiceProjectServiceContainer ' ]));
3442 }
3543
3644 public function testResetService ()
@@ -47,8 +55,8 @@ public function testResetService()
4755 $ registry ->resetManager ();
4856
4957 $ this ->assertSame ($ foo , $ container ->get ('foo ' ));
50- $ this ->assertInstanceOf (\stdClass ::class, $ foo );
51- $ this ->assertFalse (property_exists ($ foo, ' bar ' ));
58+ $ this ->assertInstanceOf (ObjectManager ::class, $ foo );
59+ $ this ->assertFalse (isset ($ foo-> bar ));
5260 }
5361
5462 /**
@@ -80,7 +88,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
8088
8189 $ service = $ container ->get ('foo ' );
8290
83- self ::assertInstanceOf (\stdClass ::class, $ service );
91+ self ::assertInstanceOf (DummyManager ::class, $ service );
8492 self ::assertInstanceOf (LazyLoadingInterface::class, $ service );
8593 self ::assertInstanceOf (ValueHolderInterface::class, $ service );
8694 self ::assertFalse ($ service ->isProxyInitialized ());
@@ -94,7 +102,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
94102 $ service ->initializeProxy ();
95103
96104 $ wrappedValue = $ service ->getWrappedValueHolderValue ();
97- self ::assertInstanceOf (\stdClass ::class, $ wrappedValue );
105+ self ::assertInstanceOf (DummyManager ::class, $ wrappedValue );
98106 self ::assertNotInstanceOf (LazyLoadingInterface::class, $ wrappedValue );
99107 self ::assertNotInstanceOf (ValueHolderInterface::class, $ wrappedValue );
100108 }
@@ -107,7 +115,7 @@ private function dumpLazyServiceProjectAsFilesServiceContainer()
107115
108116 $ container = new ContainerBuilder ();
109117
110- $ container ->register ('foo ' , \stdClass ::class)
118+ $ container ->register ('foo ' , DummyManager ::class)
111119 ->setPublic (true )
112120 ->setLazy (true );
113121 $ container ->compile ();
0 commit comments