Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dcfccf6

Browse filesBrowse files
committed
[HttpKernel] Refactor a test case to use a data provider
1 parent f07bf03 commit dcfccf6
Copy full SHA for dcfccf6

File tree

Expand file treeCollapse file tree

1 file changed

+15
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-12
lines changed

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
+15-12Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,28 @@ public function testKernelResponseDoesNotStartSession()
7070
}
7171

7272
/**
73-
* Test various types of controller callables.
73+
* @dataProvider provideControllerCallables
7474
*/
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()
7687
{
7788
// make sure we always match the line number
7889
$r1 = new \ReflectionMethod($this, 'testControllerInspection');
7990
$r2 = new \ReflectionMethod($this, 'staticControllerMethod');
8091
$r3 = new \ReflectionClass($this);
92+
8193
// test name, callable, expected
82-
$controllerTests = array(
94+
return array(
8395
array(
8496
'"Regular" callable',
8597
array($this, 'testControllerInspection'),
@@ -168,15 +180,6 @@ function () { return 'foo'; },
168180
),
169181
),
170182
);
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-
}
180183
}
181184

182185
protected function createRequest()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.