13
13
14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \DependencyInjection \Argument \ServiceClosureArgument ;
16
+ use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
17
+ use Symfony \Component \DependencyInjection \ContainerAwareTrait ;
16
18
use Symfony \Component \DependencyInjection \ContainerBuilder ;
17
19
use Symfony \Component \DependencyInjection \ContainerInterface ;
18
20
use Symfony \Component \DependencyInjection \ServiceLocator ;
@@ -187,6 +189,21 @@ public function testOptionalArgument()
187
189
$ expected = array ('bar ' => new ServiceClosureArgument (new TypedReference ('bar ' , ControllerDummy::class, RegisterTestController::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE )));
188
190
$ this ->assertEquals ($ expected , $ locator ->getArgument (0 ));
189
191
}
192
+
193
+ public function testSkipSetContainer ()
194
+ {
195
+ $ container = new ContainerBuilder ();
196
+ $ resolver = $ container ->register ('argument_resolver.service ' )->addArgument (array ());
197
+
198
+ $ container ->register ('foo ' , ContainerAwareRegisterTestController::class)
199
+ ->addTag ('controller.service_arguments ' );
200
+
201
+ $ pass = new RegisterControllerArgumentLocatorsPass ();
202
+ $ pass ->process ($ container );
203
+
204
+ $ locator = $ container ->getDefinition ((string ) $ resolver ->getArgument (0 ))->getArgument (0 );
205
+ $ this ->assertSame (array ('foo:fooAction ' ), array_keys ($ locator ));
206
+ }
190
207
}
191
208
192
209
class RegisterTestController
@@ -204,6 +221,15 @@ protected function barAction(ControllerDummy $bar)
204
221
}
205
222
}
206
223
224
+ class ContainerAwareRegisterTestController implements ContainerAwareInterface
225
+ {
226
+ use ContainerAwareTrait;
227
+
228
+ public function fooAction (ControllerDummy $ bar )
229
+ {
230
+ }
231
+ }
232
+
207
233
class ControllerDummy
208
234
{
209
235
}
0 commit comments