@@ -87,6 +87,8 @@ public function testGetControllerService()
87
87
88
88
public function testGetControllerInvokableService ()
89
89
{
90
+ $ invokableController = new InvokableController ('bar ' );
91
+
90
92
$ container = $ this ->createMockContainer ();
91
93
$ container ->expects ($ this ->once ())
92
94
->method ('has ' )
@@ -96,7 +98,7 @@ public function testGetControllerInvokableService()
96
98
$ container ->expects ($ this ->once ())
97
99
->method ('get ' )
98
100
->with ('foo ' )
99
- ->will ($ this ->returnValue ($ this ))
101
+ ->will ($ this ->returnValue ($ invokableController ))
100
102
;
101
103
102
104
$ resolver = $ this ->createControllerResolver (null , null , $ container );
@@ -105,7 +107,33 @@ public function testGetControllerInvokableService()
105
107
106
108
$ controller = $ resolver ->getController ($ request );
107
109
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 );
109
137
}
110
138
111
139
/**
@@ -178,3 +206,14 @@ public function __invoke()
178
206
{
179
207
}
180
208
}
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