Skip to content

Commit

Permalink
Ported tests from doctrine#2487 and doctrine#2489
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jan 14, 2017
1 parent 3e964f5 commit c9b86c2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/Doctrine/Tests/DBAL/Functional/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,45 @@ public function testFetchLongBlob()
);
$this->assertSame($data, stream_get_contents($stream));
}

public function testIncompletelyFetchedStatementDoesNotBlockConnection()
{
$table = new Table('stmt_test_non_fetched');
$table->addColumn('id', 'integer');
$this->_conn->getSchemaManager()->createTable($table);
$this->_conn->insert('stmt_test_non_fetched', array('id' => 1));
$this->_conn->insert('stmt_test_non_fetched', array('id' => 2));

$stmt1 = $this->_conn->prepare('SELECT id FROM stmt_test_non_fetched');
$stmt1->execute();
$stmt1->fetch();
$stmt1->execute();
// fetching only one record out of two
$stmt1->fetch();

$stmt2 = $this->_conn->prepare('SELECT id FROM stmt_test_non_fetched WHERE id = ?');
$stmt2->execute(array(1));
$this->assertEquals(1, $stmt2->fetchColumn());
}

public function testReuseStatementAfterClosingCursor()
{
$table = new Table('stmt_test_close_cursor');
$table->addColumn('id', 'integer');
$this->_conn->getSchemaManager()->createTable($table);
$this->_conn->insert('stmt_test_close_cursor', array('id' => 1));
$this->_conn->insert('stmt_test_close_cursor', array('id' => 2));

$stmt = $this->_conn->prepare('SELECT id FROM stmt_test_close_cursor WHERE id = ?');

$stmt->execute(array(1));
$id = $stmt->fetchColumn();
$this->assertEquals(1, $id);

$stmt->closeCursor();

$stmt->execute(array(2));
$id = $stmt->fetchColumn();
$this->assertEquals(2, $id);
}
}

0 comments on commit c9b86c2

Please sign in to comment.