@@ -87,6 +87,8 @@ public function testGetControllerService()
8787
8888 public function testGetControllerInvokableService ()
8989 {
90+ $ invokableController = new InvokableController ('bar ' );
91+
9092 $ container = $ this ->createMockContainer ();
9193 $ container ->expects ($ this ->once ())
9294 ->method ('has ' )
@@ -96,7 +98,7 @@ public function testGetControllerInvokableService()
9698 $ container ->expects ($ this ->once ())
9799 ->method ('get ' )
98100 ->with ('foo ' )
99- ->will ($ this ->returnValue ($ this ))
101+ ->will ($ this ->returnValue ($ invokableController ))
100102 ;
101103
102104 $ resolver = $ this ->createControllerResolver (null , null , $ container );
@@ -105,7 +107,33 @@ public function testGetControllerInvokableService()
105107
106108 $ controller = $ resolver ->getController ($ request );
107109
108- $ this ->assertInstanceOf (get_class ($ this ), $ controller );
110+ $ this ->assertEquals ($ invokableController , $ controller );
111+ }
112+
113+ public function testGetControllerInvokableServiceWithClassNameAsName ()
114+ {
115+ $ invokableController = new InvokableController ('bar ' );
116+ $ className = __NAMESPACE__ .'\InvokableController ' ;
117+
118+ $ container = $ this ->createMockContainer ();
119+ $ container ->expects ($ this ->once ())
120+ ->method ('has ' )
121+ ->with ($ className )
122+ ->will ($ this ->returnValue (true ))
123+ ;
124+ $ container ->expects ($ this ->once ())
125+ ->method ('get ' )
126+ ->with ($ className )
127+ ->will ($ this ->returnValue ($ invokableController ))
128+ ;
129+
130+ $ resolver = $ this ->createControllerResolver (null , null , $ container );
131+ $ request = Request::create ('/ ' );
132+ $ request ->attributes ->set ('_controller ' , $ className );
133+
134+ $ controller = $ resolver ->getController ($ request );
135+
136+ $ this ->assertEquals ($ invokableController , $ controller );
109137 }
110138
111139 /**
@@ -178,3 +206,14 @@ public function __invoke()
178206 {
179207 }
180208}
209+
210+ class InvokableController
211+ {
212+ public function __construct ($ bar ) // mandatory argument to prevent automatic instantiation
213+ {
214+ }
215+
216+ public function __invoke ()
217+ {
218+ }
219+ }
0 commit comments