Skip to content

Commit

Permalink
[HttpKernel] Fix a regression in the RequestDataCollector
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Oct 18, 2016
1 parent 26b90e4 commit 57008ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Expand Up @@ -374,7 +374,7 @@ protected function parseController($controller)
);
}

return (string) $controller ?: 'n/a';
return is_string($controller) ? $controller : 'n/a';
}

private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly)
Expand Down
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\HttpKernel\Tests\DataCollector;

use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
Expand Down Expand Up @@ -182,6 +183,17 @@ function () { return 'foo'; },
);
}

public function testItIgnoresInvalidCallables()
{
$request = $this->createRequestWithSession();
$response = new RedirectResponse('/');

$c = new RequestDataCollector();
$c->collect($request, $response);

$this->assertSame('n/a', $c->getController());
}

protected function createRequest()
{
$request = Request::create('http://test.com/foo?bar=baz');
Expand All @@ -194,6 +206,16 @@ protected function createRequest()
return $request;
}

private function createRequestWithSession()
{
$request = $this->createRequest();
$request->attributes->set('_controller', 'Foo::bar');
$request->setSession(new Session(new MockArraySessionStorage()));
$request->getSession()->start();

return $request;
}

protected function createResponse()
{
$response = new Response();
Expand Down

0 comments on commit 57008ea

Please sign in to comment.