Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adds tests of regression for the removal of double-stringification
  • Loading branch information
francoispluchino committed Mar 3, 2014
commit 023c3f84c52e3fdff50c7c796f1fd4a5d4aaf826
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