12
12
namespace Symfony \Bridge \ProxyManager \Tests \LazyProxy \Dumper ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
- use ProxyManager \ProxyGenerator \LazyLoading \MethodGenerator \StaticProxyConstructor ;
16
15
use Symfony \Bridge \ProxyManager \LazyProxy \PhpDumper \ProxyDumper ;
17
16
use Symfony \Component \DependencyInjection \ContainerBuilder ;
18
17
use Symfony \Component \DependencyInjection \Dumper \PhpDumper ;
@@ -27,21 +26,9 @@ class PhpDumperTest extends TestCase
27
26
{
28
27
public function testDumpContainerWithProxyService ()
29
28
{
30
- $ container = new ContainerBuilder ();
31
-
32
- $ container ->register ('foo ' , 'stdClass ' );
33
- $ container ->getDefinition ('foo ' )->setLazy (true );
67E6
tr>34
- $ container ->compile ();
35
-
36
- $ dumper = new PhpDumper ($ container );
37
-
38
- $ dumper ->setProxyDumper (new ProxyDumper ());
39
-
40
- $ dumpedString = $ dumper ->dump ();
41
-
42
29
$ this ->assertStringMatchesFormatFile (
43
30
__DIR__ .'/../Fixtures/php/lazy_service_structure.txt ' ,
44
- $ dumpedString ,
31
+ $ this -> dumpLazyServiceProjectServiceContainer () ,
45
32
'->dump() does generate proxy lazy loading logic. '
46
33
);
47
34
}
@@ -51,17 +38,15 @@ public function testDumpContainerWithProxyService()
51
38
*/
52
39
public function testDumpContainerWithProxyServiceWillShareProxies ()
53
40
{
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 ());
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