Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitaa75adf

Browse files
committed
bug#20239 [HttpKernel] Fix a regression in the RequestDataCollector (jakzal)
This PR was merged into the 3.1 branch.Discussion----------[HttpKernel] Fix a regression in the RequestDataCollector| Q | A| ------------- | ---| Branch? | 3.1| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#19701| License | MIT| Doc PR | -The regression was introduced by refactoring made as part of#17589 (if/else statements where rearranged).Commits-------57008ea [HttpKernel] Fix a regression in the RequestDataCollector26b90e4 [HttpKernel] Refactor a RequestDataCollector test case to use a data provider
2 parents57f8d1e +57008ea commitaa75adf

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

‎src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ protected function parseController($controller)
374374
);
375375
}
376376

377-
return(string)$controller?:'n/a';
377+
returnis_string($controller) ?$controller :'n/a';
378378
}
379379

380380
privatefunctiongetCookieHeader($name,$value,$expires,$path,$domain,$secure,$httponly)

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

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespaceSymfony\Component\HttpKernel\Tests\DataCollector;
1313

14+
useSymfony\Component\HttpFoundation\RedirectResponse;
1415
useSymfony\Component\HttpFoundation\Session\Session;
1516
useSymfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1617
useSymfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
@@ -70,16 +71,28 @@ public function testKernelResponseDoesNotStartSession()
7071
}
7172

7273
/**
73-
*Test various types of controller callables.
74+
*@dataProvider provideControllerCallables
7475
*/
75-
publicfunctiontestControllerInspection()
76+
publicfunctiontestControllerInspection($name,$callable,$expected)
77+
{
78+
$c =newRequestDataCollector();
79+
$request =$this->createRequest();
80+
$response =$this->createResponse();
81+
$this->injectController($c,$callable,$request);
82+
$c->collect($request,$response);
83+
84+
$this->assertSame($expected,$c->getController(),sprintf('Testing: %s',$name));
85+
}
86+
87+
publicfunctionprovideControllerCallables()
7688
{
7789
// make sure we always match the line number
7890
$r1 =new \ReflectionMethod($this,'testControllerInspection');
7991
$r2 =new \ReflectionMethod($this,'staticControllerMethod');
8092
$r3 =new \ReflectionClass($this);
93+
8194
// test name, callable, expected
82-
$controllerTests =array(
95+
returnarray(
8396
array(
8497
'"Regular" callable',
8598
array($this,'testControllerInspection'),
@@ -168,15 +181,17 @@ function () { return 'foo'; },
168181
),
169182
),
170183
);
184+
}
185+
186+
publicfunctiontestItIgnoresInvalidCallables()
187+
{
188+
$request =$this->createRequestWithSession();
189+
$response =newRedirectResponse('/');
171190

172191
$c =newRequestDataCollector();
173-
$request =$this->createRequest();
174-
$response =$this->createResponse();
175-
foreach ($controllerTestsas$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-
}
192+
$c->collect($request,$response);
193+
194+
$this->assertSame('n/a',$c->getController());
180195
}
181196

182197
protectedfunctioncreateRequest()
@@ -191,6 +206,16 @@ protected function createRequest()
191206
return$request;
192207
}
193208

209+
privatefunctioncreateRequestWithSession()
210+
{
211+
$request =$this->createRequest();
212+
$request->attributes->set('_controller','Foo::bar');
213+
$request->setSession(newSession(newMockArraySessionStorage()));
214+
$request->getSession()->start();
215+
216+
return$request;
217+
}
218+
194219
protectedfunctioncreateResponse()
195220
{
196221
$response =newResponse();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp