8000 [Bug][DataCollector] Fix the regression caused by the removal of double-stringification by francoispluchino · Pull Request #10361 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Bug][DataCollector] Fix the regression caused by the removal of double-stringification #10361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function collect(Request $request, Response $response, \Exception $except
foreach ($request->attributes->all() as $key => $value) {
if ('_route' === $key && is_object($value)) {
$value = $value->getPath();
} elseif (is_object($value)) {
$value = $this->varToString($value);
}

$attributes[$key] = $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ function () { return 'foo'; },
}
}

/**
* Test data collector serialisation.
*
* @dataProvider provider
*/
public function testDataCollectorSerialization(Request $request, Response $response)
{
if (class_exists('Symfony\Component\HttpFoundation\Session\Session') && class_exists('PDO')) {
$c = new RequestDataCollector();
$c->collect($request, $response);
$this->assertContains('"Object(Symfony\Component\HttpFoundation\Session\Session)"', $c->serialize());
} else {
$this->markTestSkipped('"Symfony\Component\HttpFoundation\Session\Session" or "PDO" class does not exists');
}
}

public function provider()
{
if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
Expand All @@ -155,6 +171,15 @@ public function provider()
$request->attributes->set('_route', 'foobar');
$request->attributes->set('_route_params', array('name' => 'foo'));

if (class_exists('Symfony\Component\HttpFoundation\Session\Session') && class_exists('PDO')) {
$pdo = new \PDO("sqlite::memory:");
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler($pdo, array('db_table' => 'sessions'));
$bridge = new \Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage($handler);
$session = new \Symfony\Component\HttpFoundation\Session\Session($bridge);
$request->attributes->set('session', $session);
}

$response = new Response();
$response->setStatusCode(200);
$response->headers->set('Content-Type', 'application/json');
Expand Down
0