From b1d5eedb4734e84fbce5265cae3946b299244bc1 Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 23 Nov 2006 23:23:24 +0000 Subject: [PATCH] Updated test cases --- lib/Doctrine/Connection.php | 1 + lib/Doctrine/Export.php | 2 +- lib/Doctrine/Export/Firebird/Exception.php | 33 ++++++++++++++++ lib/Doctrine/Export/Mysql/Exception.php | 33 ++++++++++++++++ lib/Doctrine/Transaction/Firebird.php | 8 ++-- tests/DataDict/PgsqlTestCase.php | 10 ++--- tests/DriverTestCase.php | 7 +++- tests/ExportMysqlTestCase.php | 2 +- tests/ExportTestCase.php | 4 +- tests/TransactionFirebirdTestCase.php | 20 +++++----- tests/TransactionMssqlTestCase.php | 4 +- tests/TransactionOracleTestCase.php | 2 +- tests/TransactionSqliteTestCase.php | 12 +++--- tests/run.php | 46 ++++++++++++++++++++-- 14 files changed, 145 insertions(+), 39 deletions(-) create mode 100644 lib/Doctrine/Export/Firebird/Exception.php create mode 100644 lib/Doctrine/Export/Mysql/Exception.php diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index 7aea5e3b8..a22f2d950 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -206,6 +206,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) { return $str; } + return $str; //$str = str_replace($this->identifier_quoting['end'], $this->identifier_quoting['escape'] . $this->identifier_quoting['end'], $str); //return $this->identifier_quoting['start'] . $str . $this->identifier_quoting['end']; } diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index 1fa3bcd5a..fb1bab7b3 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -227,7 +227,7 @@ class Doctrine_Export extends Doctrine_Connection_Module { $table = $this->conn->quoteIdentifier($table); $name = $this->conn->quoteIdentifier($name); - $query = 'CREATE INDEX ' . $name . ' ON ' . $table; + $query = 'CREATE INDEX ' . $name . ' ON ' . $table; $fields = array(); foreach (array_keys($definition['fields']) as $field) { $fields[] = $this->conn->quoteIdentifier($field); diff --git a/lib/Doctrine/Export/Firebird/Exception.php b/lib/Doctrine/Export/Firebird/Exception.php new file mode 100644 index 000000000..33c5e041c --- /dev/null +++ b/lib/Doctrine/Export/Firebird/Exception.php @@ -0,0 +1,33 @@ +. + */ +Doctrine::autoload('Doctrine_Export_Exception'); +/** + * Doctrine_Export_Firebird_Exception + * + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception { } diff --git a/lib/Doctrine/Export/Mysql/Exception.php b/lib/Doctrine/Export/Mysql/Exception.php new file mode 100644 index 000000000..ffdea672c --- /dev/null +++ b/lib/Doctrine/Export/Mysql/Exception.php @@ -0,0 +1,33 @@ +. + */ +Doctrine::autoload('Doctrine_Export_Exception'); +/** + * Doctrine_Export_Mysql_Exception + * + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ +class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception { } diff --git a/lib/Doctrine/Transaction/Firebird.php b/lib/Doctrine/Transaction/Firebird.php index 2b82e2aab..3de3f0024 100644 --- a/lib/Doctrine/Transaction/Firebird.php +++ b/lib/Doctrine/Transaction/Firebird.php @@ -101,8 +101,10 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction { default: throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation); } + + $rw = $wait = ''; - if( ! empty($options['wait'])) { + if(isset($options['wait'])) { switch ($options['wait']) { case 'WAIT': case 'NO WAIT': @@ -113,11 +115,11 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction { } } - if( ! empty($options['rw'])) { + if(isset($options['rw'])) { switch ($options['rw']) { case 'READ ONLY': case 'READ WRITE': - $rw = ' ' . $options['wait']; + $rw = ' ' . $options['rw']; break; default: throw new Doctrine_Transaction_Exception('wait option is not supported: ' . $options['rw']); diff --git a/tests/DataDict/PgsqlTestCase.php b/tests/DataDict/PgsqlTestCase.php index 6c0f6297b..4a1176dd1 100644 --- a/tests/DataDict/PgsqlTestCase.php +++ b/tests/DataDict/PgsqlTestCase.php @@ -1,13 +1,9 @@ dict->getDoctrineDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 2, 'fixed' => true)); + return $this->dataDict->getDoctrineDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 2, 'fixed' => true)); } public function testGetDoctrineDefinition() { - $this->dict = new Doctrine_DataDict_Pgsql(); - $this->assertEqual($this->getDeclaration('smallint'), array(array('integer', 'boolean'), 2, false, null)); $this->assertEqual($this->getDeclaration('int2'), array(array('integer', 'boolean'), 2, false, null)); @@ -16,7 +12,7 @@ class Doctrine_DataDict_Pgsql_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->getDeclaration('integer'), array(array('integer'), 4, false, null)); $this->assertEqual($this->getDeclaration('serial'), array(array('integer'), 4, false, null)); $this->assertEqual($this->getDeclaration('serial4'), array(array('integer'), 4, false, null)); - + $this->assertEqual($this->getDeclaration('bigint'), array(array('integer'), 8, false, null)); $this->assertEqual($this->getDeclaration('int8'), array(array('integer'), 8, false, null)); diff --git a/tests/DriverTestCase.php b/tests/DriverTestCase.php index 94b795729..6d128d479 100644 --- a/tests/DriverTestCase.php +++ b/tests/DriverTestCase.php @@ -77,8 +77,11 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase { if( ! $this->generic) { $this->export = $this->conn->export; - $tx = 'Doctrine_Transaction_' . ucwords($this->adapter->getName()); - if(class_exists($tx)) + if($this->adapter->getName() == 'oci') + $tx = 'Doctrine_Transaction_Oracle'; + else + $tx = 'Doctrine_Transaction_' . ucwords($this->adapter->getName()); + if(class_exists($tx)) $this->transaction = new $tx($this->conn); //$this->dataDict = $this->conn->dataDict; } else { diff --git a/tests/ExportMysqlTestCase.php b/tests/ExportMysqlTestCase.php index 3ebb943c6..0f703bfb4 100644 --- a/tests/ExportMysqlTestCase.php +++ b/tests/ExportMysqlTestCase.php @@ -1,5 +1,5 @@ export->createTable(0,array(),array()); + $this->export->createTable(0, array(), array()); $this->fail(); } catch(Doctrine_Export_Exception $e) { @@ -13,7 +13,7 @@ class Doctrine_Export_TestCase extends Doctrine_Driver_UnitTestCase { } public function testCreateTableThrowsExceptionWithEmptyFieldsArray() { try { - $this->export->createTable('sometable',array(),array()); + $this->export->createTable('sometable', array(), array()); $this->fail(); } catch(Doctrine_Export_Exception $e) { diff --git a/tests/TransactionFirebirdTestCase.php b/tests/TransactionFirebirdTestCase.php index 765c65551..0d46cf427 100644 --- a/tests/TransactionFirebirdTestCase.php +++ b/tests/TransactionFirebirdTestCase.php @@ -1,5 +1,5 @@ transaction->setIsolation('READ UNCOMMITTED'); $this->transaction->setIsolation('READ COMMITTED'); $this->transaction->setIsolation('REPEATABLE READ'); - $this->transaction->setIsolation('SERIALIZABLE'); + $this->transaction->setIsolation('SERIALIZABLE'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL READ COMMITTED RECORD_VERSION'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL READ COMMITTED NO RECORD_VERSION'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SNAPSHOT'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + $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(), 'ALTER SESSION READ ONLY ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + $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(), 'ALTER SESSION READ WRITE ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + $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(), 'ALTER SESSION NO WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + $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(), 'ALTER SESSION WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); + $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'); } } diff --git a/tests/TransactionMssqlTestCase.php b/tests/TransactionMssqlTestCase.php index d69462a63..ed176325f 100644 --- a/tests/TransactionMssqlTestCase.php +++ b/tests/TransactionMssqlTestCase.php @@ -1,7 +1,7 @@ transaction->setIsolation('REPEATABLE READ'); $this->transaction->setIsolation('SERIALIZABLE'); - $this->assertEqual($this->adapter->pop(), 'ALTER SESSION ISOLATION LEVEL READ UNCOMMITTED'); $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/TransactionSqliteTestCase.php b/tests/TransactionSqliteTestCase.php index a0412e8ba..c30955498 100644 --- a/tests/TransactionSqliteTestCase.php +++ b/tests/TransactionSqliteTestCase.php @@ -1,5 +1,5 @@ transaction->setIsolation('READ UNCOMMITTED'); $this->transaction->setIsolation('READ COMMITTED'); $this->transaction->setIsolation('REPEATABLE READ'); - $this->transaction->setIsolation('SERIALIZABLE'); - + $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'); - $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'); } } diff --git a/tests/run.php b/tests/run.php index c607839d3..0ddeae19f 100644 --- a/tests/run.php +++ b/tests/run.php @@ -3,6 +3,7 @@ ob_start(); require_once('ConfigurableTestCase.php'); +require_once('DriverTestCase.php'); require_once('ManagerTestCase.php'); require_once('ConnectionTestCase.php'); require_once('ConnectionTransactionTestCase.php'); @@ -61,6 +62,19 @@ require_once('EnumTestCase.php'); require_once('DataDictSqliteTestCase.php'); require_once('DataDict/PgsqlTestCase.php'); +require_once('ExportTestCase.php'); +require_once('ExportMysqlTestCase.php'); +require_once('ExportFirebirdTestCase.php'); +require_once('ExportPgsqlTestCase.php'); +require_once('ExportOracleTestCase.php'); + +require_once('TransactionTestCase.php'); +require_once('TransactionMysqlTestCase.php'); +require_once('TransactionPgsqlTestCase.php'); +require_once('TransactionOracleTestCase.php'); +require_once('TransactionFirebirdTestCase.php'); +require_once('TransactionMssqlTestCase.php'); +require_once('TransactionSqliteTestCase.php'); require_once('CustomResultSetOrderTestCase.php'); @@ -68,6 +82,34 @@ error_reporting(E_ALL); print '
';
 
 $test = new GroupTest('Doctrine Framework Unit Tests');
+ /**
+$test->addTestCase(new Doctrine_Configurable_TestCase());
+
+$test->addTestCase(new Doctrine_Export_Mysql_TestCase());
+
+$test->addTestCase(new Doctrine_Export_Firebird_TestCase());
+
+$test->addTestCase(new Doctrine_Export_Pgsql_TestCase());
+
+$test->addTestCase(new Doctrine_Export_Oracle_TestCase());
+
+$test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
+
+$test->addTestCase(new Doctrine_Transaction_TestCase());
+
+$test->addTestCase(new Doctrine_Transaction_Mysql_TestCase());
+
+$test->addTestCase(new Doctrine_Transaction_Pgsql_TestCase());
+
+$test->addTestCase(new Doctrine_Transaction_Oracle_TestCase());
+
+$test->addTestCase(new Doctrine_Transaction_Firebird_TestCase());
+
+$test->addTestCase(new Doctrine_Transaction_Sqlite_TestCase());
+
+$test->addTestCase(new Doctrine_Transaction_Mssql_TestCase());
+*/
+$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
 
 $test->addTestCase(new Doctrine_UnitOfWork_TestCase());
 
@@ -81,9 +123,7 @@ $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
 
 $test->addTestCase(new Doctrine_Record_TestCase());
 
-$test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
 
-$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
 
 $test->addTestCase(new Doctrine_Relation_TestCase());
 
@@ -107,8 +147,6 @@ $test->addTestCase(new Doctrine_ManagerTestCase());
 
 $test->addTestCase(new Doctrine_BatchIteratorTestCase());
 
-$test->addTestCase(new Doctrine_ConfigurableTestCase());
-
 //$test->addTestCase(new Doctrine_Collection_Offset_TestCase());
 
 $test->addTestCase(new Doctrine_PessimisticLockingTestCase());