@@ -27,21 +27,9 @@ class PhpDumperTest extends TestCase
27
27
{
28
28
public function testDumpContainerWithProxyService ()
29
29
{
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
-
42
30
$ this ->assertStringMatchesFormatFile (
43
31
__DIR__ .'/../Fixtures/php/lazy_service_structure.txt ' ,
44
- $ dumpedString ,
32
+ $ this -> dumpLazyServiceProjectServiceContainer () ,
45
33
'->dump() does generate proxy lazy loading logic. '
46
34
);
47
35
}
@@ -51,17 +39,15 @@ public function testDumpContainerWithProxyService()
51
39
*/
52
40
public function testDumpContainerWithProxyServiceWillShareProxies ()
53
41
{
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 ' ;
42
+ if (!class_exists ('LazyServiceProjectServiceContainer ' , false )) {
43
+ eval ('?> ' .$ this ->dumpLazyServiceProjectServiceContainer ());
58
44
}
59
45
60
46
$ container = new \LazyServiceProjectServiceContainer ();
61
47
62
- /* @var $proxy \stdClass_c1d194250ee2e2b7d2eab8b8212368a8 */
63
48
$ proxy = $ container ->get ('foo ' );
64
- $ this ->assertInstanceOf ('stdClass_c1d194250ee2e2b7d2eab8b8212368a8 ' , $ proxy );
49
+ $ this ->assertInstanceOf ('stdClass ' , $ proxy );
50
+ $ this ->assertInstanceOf ('ProxyManager\Proxy\LazyLoadingInterface ' , $ proxy );
65
51
$ this ->assertSame ($ proxy , $ container ->get ('foo ' ));
66
52
67
53
$ this ->assertFalse ($ proxy ->isProxyInitialized ());
@@ -71,4 +57,19 @@ public function testDumpContainerWithProxyServiceWillShareProxies()
71
57
$ this ->assertTrue ($ proxy ->isProxyInitialized ());
72
58
$ this ->assertSame ($ proxy , $ container ->get ('foo ' ));
73
59
}
60
+
61
+ private function dumpLazyServiceProjectServiceContainer ()
62
+ {
63
+ $ container = new ContainerBuilder ();
64
+
65
+ $ container ->register ('foo ' , 'stdClass ' );
66
+ $ container ->getDefinition ('foo ' )->setLazy (true );
67
+ $ container ->compile ();
68
+
69
+ $ dumper = new PhpDumper ($ container );
70
+
71
+ $ dumper ->setProxyDumper (new ProxyDumper ());
72
+
73
+ return $ dumper ->dump (array ('class ' => 'LazyServiceProjectServiceContainer ' ));
74
+ }
74
75
}
0 commit comments