Skip to content

Commit

Permalink
Merge pull request #784 from weaverryan/prove-connection-closed-test-…
Browse files Browse the repository at this point in the history
…flawed

"Breaking" a test temporarily to show that it's not doing what is expect...
  • Loading branch information
deeky666 committed Jan 10, 2016
2 parents 44ab7bc + 9d8be7b commit 61f09ce
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/Doctrine/Tests/DBAL/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,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

0 comments on commit 61f09ce

Please sign in to comment.