From bd46df215d66fbda5abf3076a62e061544901eee Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 7 Jan 2007 23:52:15 +0000 Subject: [PATCH] --- tests/DriverTestCase.php | 11 ++++-- tests/Sequence/Db2.php | 36 ------------------- .../{Firebird.php => FirebirdTestCase.php} | 4 +-- .../{Informix.php => InformixTestCase.php} | 4 +-- .../Sequence/{Mssql.php => MssqlTestCase.php} | 4 +-- .../Sequence/{Mysql.php => MysqlTestCase.php} | 23 ++++++++++-- .../{Oracle.php => OracleTestCase.php} | 4 +-- .../Sequence/{Pgsql.php => PgsqlTestCase.php} | 4 +-- .../{Sqlite.php => SqliteTestCase.php} | 4 +-- tests/UnitTestCase.php | 1 + tests/run.php | 21 ++++++++--- 11 files changed, 53 insertions(+), 63 deletions(-) delete mode 100644 tests/Sequence/Db2.php rename tests/Sequence/{Firebird.php => FirebirdTestCase.php} (96%) rename tests/Sequence/{Informix.php => InformixTestCase.php} (96%) rename tests/Sequence/{Mssql.php => MssqlTestCase.php} (96%) rename tests/Sequence/{Mysql.php => MysqlTestCase.php} (61%) rename tests/Sequence/{Oracle.php => OracleTestCase.php} (96%) rename tests/Sequence/{Pgsql.php => PgsqlTestCase.php} (96%) rename tests/Sequence/{Sqlite.php => SqliteTestCase.php} (96%) diff --git a/tests/DriverTestCase.php b/tests/DriverTestCase.php index 4f1e44f06..bcb98e309 100644 --- a/tests/DriverTestCase.php +++ b/tests/DriverTestCase.php @@ -57,7 +57,11 @@ class AdapterMock implements Doctrine_Adapter_Interface { return 0; } - public function lastInsertId(){ } + public function lastInsertId() + { + $this->queries[] = 'LAST_INSERT_ID()'; + return 1; + } public function beginTransaction(){ $this->queries[] = 'BEGIN TRANSACTION'; } @@ -67,7 +71,7 @@ class AdapterMock implements Doctrine_Adapter_Interface { public function rollBack(){ } public function errorCode(){ } public function errorInfo(){ } - public function getAttribute($attribute) { + public function getAttribute($attribute) { if($attribute == PDO::ATTR_DRIVER_NAME) return strtolower($this->name); } @@ -85,6 +89,9 @@ class AdapterStatementMock { public function execute() { return true; } + public function fetchColumn($colnum) { + return 0; + } } class Doctrine_Driver_UnitTestCase extends UnitTestCase { diff --git a/tests/Sequence/Db2.php b/tests/Sequence/Db2.php deleted file mode 100644 index 4fce6b62e..000000000 --- a/tests/Sequence/Db2.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -/** - * Doctrine_Sequence_Db2_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_Sequence_Db2_TestCase extends Doctrine_UnitTestCase -{ - -} diff --git a/tests/Sequence/Firebird.php b/tests/Sequence/FirebirdTestCase.php similarity index 96% rename from tests/Sequence/Firebird.php rename to tests/Sequence/FirebirdTestCase.php index 517d61fdb..52255a0ac 100644 --- a/tests/Sequence/Firebird.php +++ b/tests/Sequence/FirebirdTestCase.php @@ -30,7 +30,5 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Firebird_TestCase extends Doctrine_UnitTestCase -{ - +class Doctrine_Sequence_Firebird_TestCase extends Doctrine_UnitTestCase { } diff --git a/tests/Sequence/Informix.php b/tests/Sequence/InformixTestCase.php similarity index 96% rename from tests/Sequence/Informix.php rename to tests/Sequence/InformixTestCase.php index d4cdd1f7e..aaf0b4e0b 100644 --- a/tests/Sequence/Informix.php +++ b/tests/Sequence/InformixTestCase.php @@ -30,7 +30,5 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Informix_TestCase extends Doctrine_UnitTestCase -{ - +class Doctrine_Sequence_Informix_TestCase extends Doctrine_UnitTestCase { } diff --git a/tests/Sequence/Mssql.php b/tests/Sequence/MssqlTestCase.php similarity index 96% rename from tests/Sequence/Mssql.php rename to tests/Sequence/MssqlTestCase.php index 6b0c7f81a..5c7c50f7e 100644 --- a/tests/Sequence/Mssql.php +++ b/tests/Sequence/MssqlTestCase.php @@ -30,7 +30,5 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Mssql_TestCase extends Doctrine_UnitTestCase -{ - +class Doctrine_Sequence_Mssql_TestCase extends Doctrine_UnitTestCase { } diff --git a/tests/Sequence/Mysql.php b/tests/Sequence/MysqlTestCase.php similarity index 61% rename from tests/Sequence/Mysql.php rename to tests/Sequence/MysqlTestCase.php index 00ef54dc2..dfc2c7f47 100644 --- a/tests/Sequence/Mysql.php +++ b/tests/Sequence/MysqlTestCase.php @@ -30,7 +30,26 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Mysql_TestCase extends Doctrine_UnitTestCase -{ +class Doctrine_Sequence_Mysql_TestCase extends Doctrine_UnitTestCase { + public function testCurrIdExecutesSql() { + $this->sequence->currId('user'); + $this->assertEqual($this->adapter->pop(), 'SELECT MAX(id) FROM user_seq'); + } + public function testNextIdExecutesSql() { + $id = $this->sequence->nextId('user'); + + $this->assertEqual($id, 1); + + $this->assertEqual($this->adapter->pop(), 'DELETE FROM user_seq WHERE id < 1'); + $this->assertEqual($this->adapter->pop(), 'LAST_INSERT_ID()'); + $this->assertEqual($this->adapter->pop(), 'INSERT INTO user_seq (id) VALUES (NULL)'); + } + 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/Oracle.php b/tests/Sequence/OracleTestCase.php similarity index 96% rename from tests/Sequence/Oracle.php rename to tests/Sequence/OracleTestCase.php index 2d6ba1f50..120873358 100644 --- a/tests/Sequence/Oracle.php +++ b/tests/Sequence/OracleTestCase.php @@ -30,7 +30,5 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Oracle_TestCase extends Doctrine_UnitTestCase -{ - +class Doctrine_Sequence_Oracle_TestCase extends Doctrine_UnitTestCase { } diff --git a/tests/Sequence/Pgsql.php b/tests/Sequence/PgsqlTestCase.php similarity index 96% rename from tests/Sequence/Pgsql.php rename to tests/Sequence/PgsqlTestCase.php index 5ca166d0b..be15f175b 100644 --- a/tests/Sequence/Pgsql.php +++ b/tests/Sequence/PgsqlTestCase.php @@ -30,7 +30,5 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase -{ - +class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase { } diff --git a/tests/Sequence/Sqlite.php b/tests/Sequence/SqliteTestCase.php similarity index 96% rename from tests/Sequence/Sqlite.php rename to tests/Sequence/SqliteTestCase.php index 1cd557b6f..4ef89f600 100644 --- a/tests/Sequence/Sqlite.php +++ b/tests/Sequence/SqliteTestCase.php @@ -30,7 +30,5 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Sequence_Sqlite_TestCase extends Doctrine_UnitTestCase -{ - +class Doctrine_Sequence_Sqlite_TestCase extends Doctrine_UnitTestCase { } diff --git a/tests/UnitTestCase.php b/tests/UnitTestCase.php index 224b70a9a..b4772025d 100644 --- a/tests/UnitTestCase.php +++ b/tests/UnitTestCase.php @@ -114,6 +114,7 @@ class Doctrine_UnitTestCase extends UnitTestCase { $this->transaction = $this->connection->transaction; $this->dataDict = $this->connection->dataDict; $this->expr = $this->connection->expression; + $this->sequence = $this->connection->sequence; } $this->unitOfWork = $this->connection->unitOfWork; $this->connection->setListener(new Doctrine_EventListener()); diff --git a/tests/run.php b/tests/run.php index 5b76535f9..2d38f8a86 100644 --- a/tests/run.php +++ b/tests/run.php @@ -54,10 +54,10 @@ print '
';
 
 $test = new GroupTest('Doctrine Framework Unit Tests');
 
-
+  $test->addTestCase(new Doctrine_Sequence_Mysql_TestCase());
 
 // DATABASE ABSTRACTION tests
-
+/**
 // Connection drivers (not yet fully tested)
 $test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
 $test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
@@ -87,6 +87,16 @@ $test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
 $test->addTestCase(new Doctrine_DataDict_Oracle_TestCase());
 $test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
 
+// Sequence module (not yet fully tested)
+$test->addTestCase(new Doctrine_Sequence_TestCase());
+$test->addTestCase(new Doctrine_Sequence_Firebird_TestCase());
+$test->addTestCase(new Doctrine_Sequence_Informix_TestCase());
+
+$test->addTestCase(new Doctrine_Sequence_Mssql_TestCase());
+$test->addTestCase(new Doctrine_Sequence_Pgsql_TestCase());
+$test->addTestCase(new Doctrine_Sequence_Oracle_TestCase());
+$test->addTestCase(new Doctrine_Sequence_Sqlite_TestCase());
+
 // Export module (not yet fully tested)
 $test->addTestCase(new Doctrine_Export_TestCase());
 $test->addTestCase(new Doctrine_Export_Reporter_TestCase());
@@ -136,6 +146,9 @@ $test->addTestCase(new Doctrine_Collection_TestCase());
 $test->addTestCase(new Doctrine_Relation_TestCase());
 $test->addTestCase(new Doctrine_Relation_Access_TestCase());
 $test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
+$test->addTestCase(new Doctrine_Relation_OneToOne_TestCase());
+
+$test->addTestCase(new Doctrine_TreeStructure_TestCase());
 
 
 // Datatypes
@@ -193,9 +206,7 @@ $test->addTestCase(new Doctrine_Query_Expression_TestCase());
 $test->addTestCase(new Doctrine_Query_Having_TestCase());
 $test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
 
-
-$test->addTestCase(new Doctrine_TreeStructure_TestCase());
-
+*/
 // Cache tests
 //$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
 //$test->addTestCase(new Doctrine_Cache_FileTestCase());