Commit 24cefe5d authored by Craig Duncan's avatar Craig Duncan

Ensure the constructor arguments are passed to custom classes

parent 9e880d97
...@@ -249,11 +249,7 @@ class Statement implements IteratorAggregate, DriverStatement ...@@ -249,11 +249,7 @@ class Statement implements IteratorAggregate, DriverStatement
*/ */
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{ {
if ($fetchArgument) { return $this->stmt->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
return $this->stmt->fetchAll($fetchMode, $fetchArgument);
}
return $this->stmt->fetchAll($fetchMode);
} }
/** /**
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Connection; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Statement; use Doctrine\DBAL\Statement;
...@@ -28,7 +29,7 @@ class StatementTest extends DbalTestCase ...@@ -28,7 +29,7 @@ class StatementTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->pdoStatement = $this->getMockBuilder(PDOStatement::class) $this->pdoStatement = $this->getMockBuilder(PDOStatement::class)
->onlyMethods(['execute', 'bindParam', 'bindValue']) ->onlyMethods(['execute', 'bindParam', 'bindValue', 'fetchAll'])
->getMock(); ->getMock();
$driverConnection = $this->createMock(DriverConnection::class); $driverConnection = $this->createMock(DriverConnection::class);
...@@ -150,4 +151,15 @@ class StatementTest extends DbalTestCase ...@@ -150,4 +151,15 @@ class StatementTest extends DbalTestCase
$statement->execute(); $statement->execute();
} }
public function testPDOCustomClassConstructorArgs() : void
{
$statement = new Statement('', $this->conn);
$this->pdoStatement->expects($this->once())
->method('fetchAll')
->with(self::equalTo(FetchMode::CUSTOM_OBJECT), self::equalTo('Example'), self::equalTo(['arg1']));
$statement->fetchAll(FetchMode::CUSTOM_OBJECT, 'Example', ['arg1']);
}
} }
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