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)) {
......
...@@ -17,6 +17,14 @@ class DBALExceptionTest extends DbalTestCase ...@@ -17,6 +17,14 @@ class DBALExceptionTest extends DbalTestCase
$e = DBALException::driverExceptionDuringQuery($driver, new \Exception, '', array('ABC', chr(128))); $e = DBALException::driverExceptionDuringQuery($driver, new \Exception, '', array('ABC', chr(128)));
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()
{ {
......
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