@@ -26,21 +26,9 @@ class PhpDumperTest extends TestCase
26
26
{
27
27
public function testDumpContainerWithProxyService ()
28
28
{
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
-
41
29
$ this ->assertStringMatchesFormatFile (
42
30
__DIR__ .'/../Fixtures/php/lazy_service_structure.txt ' ,
43
- $ dumpedString ,
31
+ $ this -> dumpLazyServiceProjectServiceContainer () ,
44
32
'->dump() does generate proxy lazy loading logic. '
45
33
);
46
34
}
@@ -50,18 +38,15 @@ public function testDumpContainerWithProxyService()
50
38
*/
51
39
public function testDumpContainerWithProxyServiceWillShareProxies ()
52
40
{
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 ());
58
43
}
59
44
60
45
$ container = new \LazyServiceProjectServiceContainer ();
61
46
62
- /* @var $proxy \stdClass_c1d194250ee2e2b7d2eab8b8212368a8 */
63
47
$ proxy = $ container ->get ('foo ' );
64
- $ this ->assertInstanceOf ('stdClass_c1d194250ee2e2b7d2eab8b8212368a8 ' , $ proxy );
48
+ $ this ->assertInstanceOf ('stdClass ' , $ proxy );
49
+ $ this ->assertInstanceOf ('ProxyManager\Proxy\LazyLoadingInterface ' , $ proxy );
65
50
$ this ->assertSame ($ proxy , $ container ->get ('foo ' ));
66
51
67
52
$ this ->assertFalse ($ proxy ->isProxyInitialized ());
@@ -71,4 +56,19 @@ public function testDumpContainerWithProxyServiceWillShareProxies()
71
56
$ this ->assertTrue ($ proxy ->isProxyInitialized ());
72
57
$ this ->assertSame ($ proxy , $ container ->get ('foo ' ));
73
58
}
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
+ }
74
74
}
0 commit comments