From 71b218e78e31ac587124160a4ce34bf227d571d0 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 27 Dec 2006 21:33:16 +0000 Subject: [PATCH] added Transaction driver test cases --- tests/Transaction/FirebirdTestCase.php | 75 ++++++++++++++++++++++++++ tests/Transaction/InformixTestCase.php | 34 ++++++++++++ tests/Transaction/MssqlTestCase.php | 30 +++++++++++ tests/Transaction/MysqlTestCase.php | 40 ++++++++++++++ tests/Transaction/OracleTestCase.php | 39 ++++++++++++++ tests/Transaction/PgsqlTestCase.php | 35 ++++++++++++ tests/Transaction/SqliteTestCase.php | 25 +++++++++ 7 files changed, 278 insertions(+) create mode 100644 tests/Transaction/FirebirdTestCase.php create mode 100644 tests/Transaction/InformixTestCase.php create mode 100644 tests/Transaction/MssqlTestCase.php create mode 100644 tests/Transaction/MysqlTestCase.php create mode 100644 tests/Transaction/OracleTestCase.php create mode 100644 tests/Transaction/PgsqlTestCase.php create mode 100644 tests/Transaction/SqliteTestCase.php diff --git a/tests/Transaction/FirebirdTestCase.php b/tests/Transaction/FirebirdTestCase.php new file mode 100644 index 000000000..8840f2442 --- /dev/null +++ b/tests/Transaction/FirebirdTestCase.php @@ -0,0 +1,75 @@ +transaction->beginTransaction('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); + } + public function testReleaseSavePointExecutesSql() { + $this->transaction->commit('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'RELEASE SAVEPOINT mypoint'); + } + public function testRollbackSavePointExecutesSql() { + $this->transaction->beginTransaction('mypoint'); + $this->transaction->rollback('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); + } + public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { + try { + $this->transaction->setIsolation('unknown'); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationThrowsExceptionOnUnknownWaitMode() { + try { + $this->transaction->setIsolation('READ UNCOMMITTED', array('wait' => 'unknown')); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationThrowsExceptionOnUnknownReadWriteMode() { + try { + $this->transaction->setIsolation('READ UNCOMMITTED', array('rw' => 'unknown')); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationExecutesSql() { + $this->transaction->setIsolation('READ UNCOMMITTED'); + $this->transaction->setIsolation('READ COMMITTED'); + $this->transaction->setIsolation('REPEATABLE READ'); + $this->transaction->setIsolation('SERIALIZABLE'); + + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT'); + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO RECORD_VERSION'); + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED RECORD_VERSION'); + } + public function testSetIsolationSupportsReadWriteOptions() { + $this->transaction->setIsolation('SERIALIZABLE', array('rw' => 'READ ONLY')); + + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION READ ONLY ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + + $this->transaction->setIsolation('SERIALIZABLE', array('rw' => 'READ WRITE')); + + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION READ WRITE ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + } + public function testSetIsolationSupportsWaitOptions() { + $this->transaction->setIsolation('SERIALIZABLE', array('wait' => 'NO WAIT')); + + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION NO WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + + $this->transaction->setIsolation('SERIALIZABLE', array('wait' => 'WAIT')); + + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + } +} diff --git a/tests/Transaction/InformixTestCase.php b/tests/Transaction/InformixTestCase.php new file mode 100644 index 000000000..a8c301124 --- /dev/null +++ b/tests/Transaction/InformixTestCase.php @@ -0,0 +1,34 @@ +. + */ + +/** + * Doctrine_Transaction_Informix_TestCase + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Transaction_Informix_TestCase extends Doctrine_UnitTestCase { +} diff --git a/tests/Transaction/MssqlTestCase.php b/tests/Transaction/MssqlTestCase.php new file mode 100644 index 000000000..ed176325f --- /dev/null +++ b/tests/Transaction/MssqlTestCase.php @@ -0,0 +1,30 @@ +transaction->setIsolation('unknown'); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationExecutesSql() { + $this->transaction->setIsolation('READ UNCOMMITTED'); + $this->transaction->setIsolation('READ COMMITTED'); + $this->transaction->setIsolation('REPEATABLE READ'); + $this->transaction->setIsolation('SERIALIZABLE'); + + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE'); + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ'); + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + } + public function testSetIsolationSupportsSnapshotMode() { + $this->transaction->setIsolation('SNAPSHOT'); + + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT'); + } +} diff --git a/tests/Transaction/MysqlTestCase.php b/tests/Transaction/MysqlTestCase.php new file mode 100644 index 000000000..a607b98a7 --- /dev/null +++ b/tests/Transaction/MysqlTestCase.php @@ -0,0 +1,40 @@ +transaction->beginTransaction('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); + } + public function testReleaseSavePointExecutesSql() { + $this->transaction->commit('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'RELEASE SAVEPOINT mypoint'); + } + public function testRollbackSavePointExecutesSql() { + $this->transaction->beginTransaction('mypoint'); + $this->transaction->rollback('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); + } + public function testGetIsolationExecutesSql() { + $this->transaction->getIsolation(); + + $this->assertEqual($this->adapter->pop(), 'SELECT @@tx_isolation'); + } + public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { + try { + $this->transaction->setIsolation('unknown'); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationExecutesSql() { + $this->transaction->setIsolation('READ UNCOMMITTED'); + + $this->assertEqual($this->adapter->pop(), 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + } +} diff --git a/tests/Transaction/OracleTestCase.php b/tests/Transaction/OracleTestCase.php new file mode 100644 index 000000000..7822518b7 --- /dev/null +++ b/tests/Transaction/OracleTestCase.php @@ -0,0 +1,39 @@ +transaction->beginTransaction('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); + } + public function testReleaseSavePointAlwaysReturnsTrue() { + $this->assertEqual($this->transaction->commit('mypoint'), true); + } + public function testRollbackSavePointExecutesSql() { + $this->transaction->beginTransaction('mypoint'); + $this->transaction->rollback('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); + } + public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { + try { + $this->transaction->setIsolation('unknown'); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationExecutesSql() { + $this->transaction->setIsolation('READ UNCOMMITTED'); + $this->transaction->setIsolation('READ COMMITTED'); + $this->transaction->setIsolation('REPEATABLE READ'); + $this->transaction->setIsolation('SERIALIZABLE'); + + $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'); + $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'); + $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'); + $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL READ COMMITTED'); + } +} diff --git a/tests/Transaction/PgsqlTestCase.php b/tests/Transaction/PgsqlTestCase.php new file mode 100644 index 000000000..780392e5a --- /dev/null +++ b/tests/Transaction/PgsqlTestCase.php @@ -0,0 +1,35 @@ +transaction->beginTransaction('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint'); + } + public function testReleaseSavePointExecutesSql() { + $this->transaction->commit('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'RELEASE SAVEPOINT mypoint'); + } + public function testRollbackSavePointExecutesSql() { + $this->transaction->beginTransaction('mypoint'); + $this->transaction->rollback('mypoint'); + + $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint'); + } + public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() { + try { + $this->transaction->setIsolation('unknown'); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationExecutesSql() { + $this->transaction->setIsolation('READ UNCOMMITTED'); + + $this->assertEqual($this->adapter->pop(), 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + } +} diff --git a/tests/Transaction/SqliteTestCase.php b/tests/Transaction/SqliteTestCase.php new file mode 100644 index 000000000..c30955498 --- /dev/null +++ b/tests/Transaction/SqliteTestCase.php @@ -0,0 +1,25 @@ +transaction->setIsolation('unknown'); + $this->fail(); + } catch(Doctrine_Transaction_Exception $e) { + $this->pass(); + } + } + public function testSetIsolationExecutesSql() { + $this->transaction->setIsolation('READ UNCOMMITTED'); + $this->transaction->setIsolation('READ COMMITTED'); + $this->transaction->setIsolation('REPEATABLE READ'); + $this->transaction->setIsolation('SERIALIZABLE'); + + $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 1'); + $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 1'); + $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 1'); + $this->assertEqual($this->adapter->pop(), 'PRAGMA read_uncommitted = 0'); + } +}