Commit cf35f193 authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #623 from jgallred/remove-extra-pdo-reference

Prevent Connection from maintaining a second reference to an injected PDO object.
parents 247bd099 731e9287
......@@ -206,6 +206,7 @@ class Connection implements DriverConnection
if (isset($params['pdo'])) {
$this->_conn = $params['pdo'];
$this->_isConnected = true;
unset($this->_params['pdo']);
}
// Create default config and event manager if none given
......
......@@ -435,4 +435,26 @@ SQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\"");
$this->assertSame($result, $conn->fetchAll($statement, $params, $types));
}
public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO()
{
$params['pdo'] = new \stdClass();
$driverMock = $this->getMock('Doctrine\DBAL\Driver');
$conn = new Connection($params, $driverMock);
$this->assertArrayNotHasKey('pdo', $conn->getParams(), "Connection is maintaining additional reference to the PDO connection");
}
public function testPassingExternalPDOMeansConnectionIsConnected()
{
$params['pdo'] = new \stdClass();
$driverMock = $this->getMock('Doctrine\DBAL\Driver');
$conn = new Connection($params, $driverMock);
$this->assertTrue($conn->isConnected(), "Connection is not connected after passing external PDO");
}
}
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