Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection is not lazy anymore, since platform detection was introduced - exposing the issue via broken test #784

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions tests/Doctrine/Tests/DBAL/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down