11
11
12
12
namespace Symfony \Bridge \Doctrine \Tests ;
13
13
14
+ use Doctrine \Persistence \ObjectManager ;
14
15
use PHPUnit \Framework \TestCase ;
15
16
use ProxyManager \Proxy \LazyLoadingInterface ;
16
17
use ProxyManager \Proxy \ValueHolderInterface ;
18
+ use Symfony \Bridge \Doctrine \Tests \Fixtures \DummyManager ;
17
19
use Symfony \Bridge \ProxyManager \LazyProxy \PhpDumper \ProxyDumper ;
18
- use Symfony \Bridge \ProxyManager \Tests \LazyProxy \Dumper \PhpDumperTest ;
19
20
use Symfony \Component \DependencyInjection \ContainerBuilder ;
20
21
use Symfony \Component \DependencyInjection \ContainerInterface ;
21
22
use Symfony \Component \DependencyInjection \Dumper \PhpDumper ;
@@ -28,9 +29,16 @@ class LegacyManagerRegistryTest extends TestCase
28
29
{
29
30
public static function setUpBeforeClass (): void
30
31
{
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 ' ]));
34
42
}
35
43
36
44
public function testResetService ()
@@ -47,8 +55,8 @@ public function testResetService()
47
55
$ registry ->resetManager ();
48
56
49
57
$ 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 ));
52
60
}
53
61
54
62
/**
@@ -80,7 +88,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
80
88
81
89
$ service = $ container ->get ('foo ' );
82
90
83
- self ::assertInstanceOf (\stdClass ::class, $ service );
91
+ self ::assertInstanceOf (DummyManager ::class, $ service );
84
92
self ::assertInstanceOf (LazyLoadingInterface::class, $ service );
85
93
self ::assertInstanceOf (ValueHolderInterface::class, $ service );
86
94
self ::assertFalse ($ service ->isProxyInitialized ());
@@ -94,7 +102,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
94
102
$ service ->initializeProxy ();
95
103
96
104
$ wrappedValue = $ service ->getWrappedValueHolderValue ();
97
- self ::assertInstanceOf (\stdClass ::class, $ wrappedValue );
105
+ self ::assertInstanceOf (DummyManager ::class, $ wrappedValue );
98
106
self ::assertNotInstanceOf (LazyLoadingInterface::class, $ wrappedValue );
99
107
self ::assertNotInstanceOf (ValueHolderInterface::class, $ wrappedValue );
100
108
}
@@ -107,7 +115,7 @@ private function dumpLazyServiceProjectAsFilesServiceContainer()
107
115
108
116
$ container = new ContainerBuilder ();
109
117
110
- $ container ->register ('foo ' , \stdClass ::class)
118
+ $ container ->register ('foo ' , DummyManager ::class)
111
119
->setPublic (true )
112
120
->setLazy (true );
113
121
$ container ->compile ();
0 commit comments