@@ -26,21 +26,9 @@ class PhpDumperTest extends TestCase
2626{
2727 public function testDumpContainerWithProxyService ()
2828 {
29- $ container = new ContainerBuilder ();
30-
31- $ container ->register ('foo ' , 'stdClass ' );
32- $ container ->getDefinition ('foo ' )->setLazy (true );
33- $ container ->compile ();
34-
35- $ dumper = new PhpDumper ($ container );
36-
37- $ dumper ->setProxyDumper (new ProxyDumper ());
38-
39- $ dumpedString = $ dumper ->dump ();
40-
4129 $ this ->assertStringMatchesFormatFile (
4230 __DIR__ .'/../Fixtures/php/lazy_service_structure.txt ' ,
43- $ dumpedString ,
31+ $ this -> dumpLazyServiceProjectServiceContainer () ,
4432 '->dump() does generate proxy lazy loading logic. '
4533 );
4634 }
@@ -50,18 +38,15 @@ public function testDumpContainerWithProxyService()
5038 */
5139 public function testDumpContainerWithProxyServiceWillShareProxies ()
5240 {
53- // detecting ProxyManager v2
54- if (class_exists ('ProxyManager\ProxyGenerator\LazyLoading\MethodGenerator\StaticProxyConstructor ' )) {
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