@@ -88,6 +88,49 @@ public function testGetControllerInvokableServiceWithClassNameAsName()
88
88
$ this ->assertEquals ($ invokableController , $ controller );
89
89
}
90
90
91
+ public function testNonInstantiableController ()
92
+ {
93
+ $ container = $ this ->createMockContainer ();
94
+ $ container ->expects ($ this ->once ())
95
+ ->method ('has ' )
96
+ ->with (NonInstantiableController::class)
97
+ ->will ($ this ->returnValue (false ))
98
+ ;
99
+
100
+ $ resolver = $ this ->createControllerResolver (null , $ container );
101
+ $ request = Request::create ('/ ' );
102
+ $ request ->attributes ->set ('_controller ' , array (NonInstantiableController::class, 'action ' ));
103
+
104
+ $ controller = $ resolver ->getController ($ request );
105
+
106
+ $ this ->assertSame (array (NonInstantiableController::class, 'action ' ), $ controller );
107
+ }
108
+
109
+ public function testNonInstantiableControllerWithCorrespondingService ()
110
+ {
111
+ $ service = new \stdClass ();
112
+
113
+ $ container = $ this ->createMockContainer ();
114
+ $ container ->expects ($ this ->atLeastOnce ())
115
+ ->method ('has ' )
116
+ ->with (NonInstantiableController::class)
117
+ ->will ($ this ->returnValue (true ))
118
+ ;
119
+ $ container ->expects ($ this ->atLeastOnce ())
120
+ ->method ('get ' )
121
+ ->with (NonInstantiableController::class)
122
+ ->will ($ this ->returnValue ($ service ))
123
+ ;
124
+
125
+ $ resolver = $ this ->createControllerResolver (null , $ container );
126
+ $ request = Request::create ('/ ' );
127
+ $ request ->attributes ->set ('_controller ' , array (NonInstantiableController::class, 'action ' ));
128
+
129
+ $ controller = $ resolver ->getController ($ request );
130
+
131
+ $ this ->assertSame (array ($ service , 'action ' ), $ controller );
132
+ }
133
+
91
134
/**
92
135
* @dataProvider getUndefinedControllers
93
136
*/
@@ -146,3 +189,10 @@ public function __invoke()
146
189
{
147
190
}
148
191
}
192
+
193
+ abstract class NonInstantiableController
194
+ {
195
+ public static function action ()
196
+ {
197
+ }
198
+ }
0 commit comments