1212namespace Symfony \Bridge \ProxyManager \Tests \LazyProxy \Dumper ;
1313
1414use PHPUnit \Framework \TestCase ;
15- use ProxyManager \ProxyGenerator \LazyLoading \MethodGenerator \StaticProxyConstructor ;
1615use Symfony \Bridge \ProxyManager \LazyProxy \PhpDumper \ProxyDumper ;
1716use Symfony \Component \DependencyInjection \ContainerBuilder ;
1817use Symfony \Component \DependencyInjection \Dumper \PhpDumper ;
@@ -27,21 +26,9 @@ class PhpDumperTest extends TestCase
2726{
2827 public function testDumpContainerWithProxyService ()
2928 {
30- $ container = new ContainerBuilder ();
31-
32- $ container ->register ('foo ' , 'stdClass ' );
33- $ container ->getDefinition ('foo ' )->setLazy (true );
34- $ container ->compile ();
35-
36- $ dumper = new PhpDumper ($ container );
37-
38- $ dumper ->setProxyDumper (new ProxyDumper ());
39-
40- $ dumpedString = $ dumper ->dump ();
41-
4229 $ this ->assertStringMatchesFormatFile (
4330 __DIR__ .'/../Fixtures/php/lazy_service_structure.txt ' ,
44- $ dumpedString ,
31+ $ this -> dumpLazyServiceProjectServiceContainer () ,
4532 '->dump() does generate proxy lazy loading logic. '
4633 );
4734 }
@@ -51,17 +38,15 @@ public function testDumpContainerWithProxyService()
5138 */
5239 public function testDumpContainerWithProxyServiceWillShareProxies ()
5340 {
54- if (class_exists (StaticProxyConstructor::class)) { // detecting ProxyManager v2
55- require_once __DIR__ .'/../Fixtures/php/lazy_service_with_hints.php ' ;
56- } else {
57- require_once __DIR__ .'/../Fixtures/php/lazy_service.php ' ;
41+ if (!class_exists ('LazyServiceProjectServiceContainer ' , false )) {
42+ eval ('?> ' .$ this ->dumpLazyServiceProjectServiceContainer ());
5843 }
5944
6045 $ container = new \LazyServiceProjectServiceContainer ();
6146
62- /* @var $proxy \stdClass_c1d194250ee2e2b7d2eab8b8212368a8 */
6347 $ proxy = $ container ->get ('foo ' );
64- $ this ->assertInstanceOf ('stdClass_c1d194250ee2e2b7d2eab8b8212368a8 ' , $ proxy );
48+ $ this ->assertInstanceOf ('stdClass ' , $ proxy );
49+ $ this ->assertInstanceOf ('ProxyManager\Proxy\LazyLoadingInterface ' , $ proxy );
6550 $ this ->assertSame ($ proxy , $ container ->get ('foo ' ));
6651
6752 $ this ->assertFalse ($ proxy ->isProxyInitialized ());
@@ -71,4 +56,19 @@ public function testDumpContainerWithProxyServiceWillShareProxies()
7156 $ this ->assertTrue ($ proxy ->isProxyInitialized ());
7257 $ this ->assertSame ($ proxy , $ container ->get ('foo ' ));
7358 }
59+
60+ private function dumpLazyServiceProjectServiceContainer ()
61+ {
62+ $ container = new ContainerBuilder ();
63+
64+ $ container ->register ('foo ' , 'stdClass ' );
65+ $ container ->getDefinition ('foo ' )->setLazy (true );
66+ $ container ->compile ();
67+
68+ $ dumper = new PhpDumper ($ container );
69+
70+ $ dumper ->setProxyDumper (new ProxyDumper ());
71+
72+ return $ dumper ->dump (array ('class ' => 'LazyServiceProjectServiceContainer ' ));
73+ }
7474}
0 commit comments