From 0833fc572d16f8f3f98811b669f9e6ce1d7f738a Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 17 Jun 2007 17:51:35 +0000 Subject: [PATCH] tests for Firebird and Mssql sequence drivers --- tests/Sequence/FirebirdTestCase.php | 23 ++++++++++++++++++++- tests/Sequence/MssqlTestCase.php | 31 ++++++++++++++++++++++++++++- tests/Sequence/PgsqlTestCase.php | 3 ++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/tests/Sequence/FirebirdTestCase.php b/tests/Sequence/FirebirdTestCase.php index 52255a0ac..ca584e669 100644 --- a/tests/Sequence/FirebirdTestCase.php +++ b/tests/Sequence/FirebirdTestCase.php @@ -30,5 +30,26 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Firebird_TestCase extends Doctrine_UnitTestCase { +class Doctrine_Sequence_Firebird_TestCase extends Doctrine_UnitTestCase +{ + public function testCurrIdExecutesSql() + { + $this->sequence->currId('user'); + + $this->assertEqual($this->adapter->pop(), 'SELECT GEN_ID(user_seq, 0) as the_value FROM RDB$DATABASE'); + } + public function testNextIdExecutesSql() + { + $id = $this->sequence->nextId('user'); + + $this->assertEqual($this->adapter->pop(), 'SELECT GEN_ID(user_seq, 1) as the_value FROM RDB$DATABASE'); + } + public function testLastInsertIdCallsPdoLevelEquivalent() + { + $id = $this->sequence->lastInsertId('user'); + + $this->assertEqual($id, 1); + + $this->assertEqual($this->adapter->pop(), 'LAST_INSERT_ID()'); + } } diff --git a/tests/Sequence/MssqlTestCase.php b/tests/Sequence/MssqlTestCase.php index 5c7c50f7e..7e05b7f05 100644 --- a/tests/Sequence/MssqlTestCase.php +++ b/tests/Sequence/MssqlTestCase.php @@ -30,5 +30,34 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Mssql_TestCase extends Doctrine_UnitTestCase { +class Doctrine_Sequence_Mssql_TestCase extends Doctrine_UnitTestCase +{ + public function testCurrIdExecutesSql() + { + $id = $this->sequence->currId('user'); + + $this->assertEqual($this->adapter->pop(), 'DELETE FROM user_seq WHERE id < 0'); + + $this->assertEqual($this->adapter->pop(), 'SELECT @@IDENTITY'); + $this->assertEqual($this->adapter->pop(), 'SELECT @@VERSION'); + $this->assertEqual($this->adapter->pop(), 'SET IDENTITY_INSERT user_seq ON INSERT INTO user_seq (id) VALUES (0)'); + $this->assertEqual($this->adapter->pop(), 'SELECT COUNT(1) FROM user_seq'); + } + public function testNextIdExecutesSql() + { + $id = $this->sequence->nextId('user'); + + $this->assertEqual($this->adapter->pop(), 'DELETE FROM user_seq WHERE id < 0'); + + $this->assertEqual($this->adapter->pop(), 'SELECT @@IDENTITY'); + $this->assertEqual($this->adapter->pop(), 'SELECT @@VERSION'); + $this->assertEqual($this->adapter->pop(), 'SET IDENTITY_INSERT user_seq ON INSERT INTO user_seq (id) VALUES (0)'); + $this->assertEqual($this->adapter->pop(), 'SELECT COUNT(1) FROM user_seq'); + } + public function testLastInsertIdCallsPdoLevelEquivalent() + { + $id = $this->sequence->lastInsertId('user'); + + $this->assertEqual($this->adapter->pop(), 'SELECT @@IDENTITY'); + } } diff --git a/tests/Sequence/PgsqlTestCase.php b/tests/Sequence/PgsqlTestCase.php index 2d355f91f..f65133f6c 100644 --- a/tests/Sequence/PgsqlTestCase.php +++ b/tests/Sequence/PgsqlTestCase.php @@ -30,7 +30,8 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase { +class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase +{ public function testCurrIdExecutesSql() { $this->sequence->currId('user');