Commit b5f90e09 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Fixed recent DBAL test failures with several open connections and Dummy Select statements

parent 3caada2b
...@@ -1901,4 +1901,14 @@ abstract class AbstractPlatform ...@@ -1901,4 +1901,14 @@ abstract class AbstractPlatform
{ {
return 'TRUNCATE '.$tableName; return 'TRUNCATE '.$tableName;
} }
/**
* This is for test reasons, many vendors have special requirements for dummy statements.
*
* @return string
*/
public function getDummySelectSQL()
{
return 'SELECT 1';
}
} }
\ No newline at end of file
...@@ -518,4 +518,9 @@ class DB2Platform extends AbstractPlatform ...@@ -518,4 +518,9 @@ class DB2Platform extends AbstractPlatform
{ {
return ' WITH RR USE AND KEEP UPDATE LOCKS'; return ' WITH RR USE AND KEEP UPDATE LOCKS';
} }
public function getDummySelectSQL()
{
return 'SELECT 1 FROM sysibm.sysdummy1';
}
} }
\ No newline at end of file
...@@ -650,4 +650,14 @@ LEFT JOIN all_cons_columns r_cols ...@@ -650,4 +650,14 @@ LEFT JOIN all_cons_columns r_cols
{ {
return 'TRUNCATE TABLE '.$tableName; return 'TRUNCATE TABLE '.$tableName;
} }
/**
* This is for test reasons, many vendors have special requirements for dummy statements.
*
* @return string
*/
public function getDummySelectSQL()
{
return 'SELECT 1 FROM DUAL';
}
} }
...@@ -88,7 +88,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -88,7 +88,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
{ {
try { try {
$this->_conn->transactional(function($conn) { $this->_conn->transactional(function($conn) {
$conn->executeQuery("select 1"); $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
throw new \RuntimeException("Ooops!"); throw new \RuntimeException("Ooops!");
}); });
} catch (\RuntimeException $expected) { } catch (\RuntimeException $expected) {
...@@ -99,7 +99,8 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -99,7 +99,8 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testTransactional() public function testTransactional()
{ {
$this->_conn->transactional(function($conn) { $this->_conn->transactional(function($conn) {
$conn->executeQuery("select 1"); /* @var $conn Connection */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
}); });
} }
} }
\ No newline at end of file
...@@ -27,8 +27,7 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -27,8 +27,7 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testExecuteUpdate() public function testExecuteUpdate()
{ {
$sql = "INSERT INTO " . $this->_conn->quoteIdentifier('write_table') . " ( " . $sql = "INSERT INTO write_table (test_int) VALUES ( " . $this->_conn->quote(1) . ")";
$this->_conn->quoteIdentifier('test_int') . " ) VALUES ( " . $this->_conn->quote(1) . ")";
$affected = $this->_conn->executeUpdate($sql); $affected = $this->_conn->executeUpdate($sql);
$this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!"); $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!");
......
...@@ -14,9 +14,15 @@ class DbalFunctionalTestCase extends DbalTestCase ...@@ -14,9 +14,15 @@ class DbalFunctionalTestCase extends DbalTestCase
protected function resetSharedConn() protected function resetSharedConn()
{ {
if ($this->sharedFixture['conn']) {
$this->sharedFixture['conn']->close();
$this->sharedFixture['conn'] = null; $this->sharedFixture['conn'] = null;
}
if (self::$_sharedConn) {
self::$_sharedConn->close();
self::$_sharedConn = null; self::$_sharedConn = null;
} }
}
protected function setUp() protected function setUp()
{ {
......
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