Unverified Commit c8e6c9c3 authored by Michael Moravec's avatar Michael Moravec Committed by GitHub

Merge pull request #2933 from holantomas/patch-1

Added test case for resource as parameter
parents 0a7eadb9 f920bda2
...@@ -190,6 +190,10 @@ class DBALException extends \Exception ...@@ -190,6 +190,10 @@ class DBALException extends \Exception
private static function formatParameters(array $params) private static function formatParameters(array $params)
{ {
return '[' . implode(', ', array_map(function ($param) { return '[' . implode(', ', array_map(function ($param) {
if (is_resource($param)) {
return (string) $param;
}
$json = @json_encode($param); $json = @json_encode($param);
if (! is_string($json) || $json == 'null' && is_string($param)) { if (! is_string($json) || $json == 'null' && is_string($param)) {
......
...@@ -18,6 +18,14 @@ class DBALExceptionTest extends DbalTestCase ...@@ -18,6 +18,14 @@ class DBALExceptionTest extends DbalTestCase
self::assertContains('with params ["ABC", "\x80"]', $e->getMessage()); self::assertContains('with params ["ABC", "\x80"]', $e->getMessage());
} }
public function testDriverExceptionDuringQueryAcceptsResource()
{
/* @var $driver Driver */
$driver = $this->createMock(Driver::class);
$e = \Doctrine\DBAL\DBALException::driverExceptionDuringQuery($driver, new \Exception, "INSERT INTO file (`content`) VALUES (?)", [1 => fopen(__FILE__, 'r')]);
self::assertContains('Resource', $e->getMessage());
}
public function testAvoidOverWrappingOnDriverException() public function testAvoidOverWrappingOnDriverException()
{ {
/* @var $driver Driver */ /* @var $driver Driver */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment