diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index bd6d123ac03..22d1b449f52 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -401,13 +401,27 @@ public function testFetchColumn() $this->assertSame($result, $conn->fetchColumn($statement, $params, $column, $types)); } - public function testConnectionIsClosed() + public function testConnectionIsClosedButNotUnset() { - $this->_conn->close(); + // mock Connection, and make connect() purposefully do nothing + $connection = $this->getMockBuilder('Doctrine\DBAL\Connection') + ->disableOriginalConstructor() + ->setMethods(array('connect')) + ->getMock(); + + // artificially set the wrapped connection to non-null + $reflection = new \ReflectionObject($connection); + $connProperty = $reflection->getProperty('_conn'); + $connProperty->setAccessible(true); + $connProperty->setValue($connection, new \stdClass); - $this->setExpectedException('Doctrine\\DBAL\\Exception\\DriverException'); + // close the connection (should nullify the wrapped connection) + $connection->close(); - $this->_conn->quoteIdentifier('Bug'); + // the wrapped connection should be null + // (and since connect() does nothing, this will not reconnect) + // this will also fail if this _conn property was unset instead of set to null + $this->assertNull($connection->getWrappedConnection()); } public function testFetchAll()