@@ -70,16 +70,28 @@ public function testKernelResponseDoesNotStartSession()
70
70
}
71
71
72
72
/**
73
- * Test various types of controller callables.
73
+ * @dataProvider provideControllerCallables
74
74
*/
75
- public function testControllerInspection ()
75
+ public function testControllerInspection ($ name , $ callable , $ expected )
76
+ {
77
+ $ c = new RequestDataCollector ();
78
+ $ request = $ this ->createRequest ();
79
+ $ response = $ this ->createResponse ();
80
+ $ this ->injectController ($ c , $ callable , $ request );
81
+ $ c ->collect ($ request , $ response );
82
+
83
+ $ this ->assertSame ($ expected , $ c ->getController (), sprintf ('Testing: %s ' , $ name ));
84
+ }
85
+
86
+ public function provideControllerCallables ()
76
87
{
77
88
// make sure we always match the line number
78
89
$ r1 = new \ReflectionMethod ($ this , 'testControllerInspection ' );
79
90
$ r2 = new \ReflectionMethod ($ this , 'staticControllerMethod ' );
80
91
$ r3 = new \ReflectionClass ($ this );
92
+
81
93
// test name, callable, expected
82
- $ controllerTests = array (
94
+ return array (
83
95
array (
84
96
'"Regular" callable ' ,
85
97
array ($ this , 'testControllerInspection ' ),
@@ -168,15 +180,6 @@ function () { return 'foo'; },
168
180
),
169
181
),
170
182
);
171
-
172
- $ c = new RequestDataCollector ();
173
- $ request = $ this ->createRequest ();
174
- $ response = $ this ->createResponse ();
175
- foreach ($ controllerTests as $ controllerTest ) {
176
- $ this ->injectController ($ c , $ controllerTest [1 ], $ request );
177
- $ c ->collect ($ request , $ response );
178
- $ this ->assertSame ($ controllerTest [2 ], $ c ->getController (), sprintf ('Testing: %s ' , $ controllerTest [0 ]));
179
- }
180
183
}
181
184
182
185
protected function createRequest ()
0 commit comments