public function PdoSessionHandlerTest::testReadLockedConvertsStreamToString in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php \Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\PdoSessionHandlerTest::testReadLockedConvertsStreamToString()
File
- vendor/
symfony/ http-foundation/ Tests/ Session/ Storage/ Handler/ PdoSessionHandlerTest.php, line 155
Class
Namespace
Symfony\Component\HttpFoundation\Tests\Session\Storage\HandlerCode
public function testReadLockedConvertsStreamToString() {
$pdo = new MockPdo('pgsql');
$selectStmt = $this
->getMock('PDOStatement');
$insertStmt = $this
->getMock('PDOStatement');
$pdo->prepareResult = function ($statement) use ($selectStmt, $insertStmt) {
return 0 === strpos($statement, 'INSERT') ? $insertStmt : $selectStmt;
};
$content = 'foobar';
$stream = $this
->createStream($content);
$exception = null;
$selectStmt
->expects($this
->atLeast(2))
->method('fetchAll')
->will($this
->returnCallback(function () use (&$exception, $stream) {
return $exception ? array(
array(
$stream,
42,
time(),
),
) : array();
}));
$insertStmt
->expects($this
->once())
->method('execute')
->will($this
->returnCallback(function () use (&$exception) {
throw $exception = new \PDOException('', '23');
}));
$storage = new PdoSessionHandler($pdo);
$result = $storage
->read('foo');
$this
->assertSame($content, $result);
}