33namespace Overblog \GraphQLBundle \Tests \DependencyInjection \Compiler ;
44
55use Overblog \GraphQLBundle \DependencyInjection \Compiler \ResolverTaggedServiceMappingPass ;
6- use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
7- use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
8- use Symfony \Component \DependencyInjection \ContainerAwareTrait ;
96use Symfony \Component \DependencyInjection \ContainerBuilder ;
107use Symfony \Component \DependencyInjection \Definition ;
11- use Symfony \Component \DependencyInjection \Reference ;
128
139/**
1410 * Class ResolverTaggedServiceMappingPassTest
@@ -34,21 +30,20 @@ public function setUp()
3430 "Overblog \\GraphQLBundle \\Resolver \\ResolverResolver "
3531 );
3632
37- $ fakeResolver = new Definition ('Overblog\GraphQLBundle\Tests\DependencyInjection\Compiler\FakeResolverService ' );
38- $ fakeResolver
33+ $ testResolver = new Definition ('Overblog\GraphQLBundle\Tests\DependencyInjection\Compiler\ResolverTestService ' );
34+ $ testResolver
3935 ->addTag ( 'overblog_graphql.resolver ' , [
40- 'alias ' => 'fake_resolver ' , 'method ' => 'doSomethingWithContainer '
36+ 'alias ' => 'test_resolver ' , 'method ' => 'doSomethingWithContainer '
4137 ]);
4238
43- $ container ->setDefinition ('fake_resolver ' , $ fakeResolver );
39+ $ container ->setDefinition ('test_resolver ' , $ testResolver );
4440
4541 $ this ->container = $ container ;
4642 }
4743
4844 private function addCompilerPassesAndCompile ()
4945 {
5046 $ this ->container ->addCompilerPass (new ResolverTaggedServiceMappingPass ());
51- // Manipulate container after ResolverTaggedServiceMappingPass
5247 $ this ->container ->addCompilerPass (new FakeCompilerPass ());
5348 $ this ->container ->compile ();
5449 }
@@ -57,40 +52,6 @@ public function testCompilationWorksPassConfigDirective()
5752 {
5853 $ this ->addCompilerPassesAndCompile ();
5954
60- $ this ->assertTrue ($ this ->container ->has ('fake_resolver ' ));
61- }
62- }
63-
64- class FakeCompilerPass implements CompilerPassInterface
65- {
66- public function process (ContainerBuilder $ container )
67- {
68- $ container
69- ->getDefinition ('fake_resolver ' )
70- ->addArgument (new Reference ('injected_service ' ))
71- ;
72- }
73- }
74-
75- // Instantiate ContainerAwareInterface to trigger the problem in ResolverTaggedServiceMappingPass
76- class FakeResolverService implements ContainerAwareInterface
77- {
78- use ContainerAwareTrait;
79-
80- public function __construct ($ service )
81- {
82- }
83-
84- public function doSomethingWithContainer ()
85- {
86- return $ this ->container ->get ('injected_service ' )->doSomething ();
87- }
88- }
89-
90- class FakeInjectedService
91- {
92- public function doSomething ()
93- {
94- return true ;
55+ $ this ->assertTrue ($ this ->container ->has ('test_resolver ' ));
9556 }
9657}
0 commit comments