@@ -119,6 +119,36 @@ public function testGetControllerInvokableServiceWithClassNameAsName()
119
119
$ this ->assertSame ($ service , $ controller );
120
120
}
121
121
122
+ /**
123
+ * @dataProvider getControllers
124
+ */
125
+ public function testInstantiateControllerWhenControllerStartsWithABackslash ($ controller )
126
+ {
127
+ $ service = new ControllerTestService ('foo ' );
128
+ $ class = ControllerTestService::class;
129
+
130
+ $ container = $ this ->createMockContainer ();
131
+ $ container ->expects ($ this ->once ())->method ('has ' )->with ($ class )->willReturn (true );
132
+ $ container ->expects ($ this ->once ())->method ('get ' )->with ($ class )->willReturn ($ service );
133
+
134
+ $ resolver = $ this ->createControllerResolver (null , $ container );
135
+ $ request = Request::create ('/ ' );
136
+ $ request ->attributes ->set ('_controller ' , $ controller );
137
+
138
+ $ controller = $ resolver ->getController ($ request );
139
+
140
+ $ this ->assertInstanceOf (ControllerTestService::class, $ controller [0 ]);
141
+ $ this ->assertSame ('action ' , $ controller [1 ]);
142
+ }
143
+
144
+ public function getControllers ()
145
+ {
146
+ return [
147
+ ['\\' .ControllerTestService::class.'::action ' ],
148
+ ['\\' .ControllerTestService::class.':action ' ],
149
+ ];
150
+ }
151
+
122
152
public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsName ()
123
153
{
124
154
$ this ->expectException ('InvalidArgumentException ' );
0 commit comments