Commit b1d5eedb authored by zYne's avatar zYne

Updated test cases

parent 70e467b7
......@@ -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'];
}
......
......@@ -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);
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception { }
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception { }
......@@ -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']);
......
<?php
class Doctrine_DataDict_Pgsql_TestCase extends Doctrine_UnitTestCase {
public function prepareTables() { }
public function prepareData() { }
class Doctrine_DataDict_Pgsql_TestCase extends Doctrine_Driver_UnitTestCase {
public function getDeclaration($type) {
return $this->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));
......
......@@ -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 {
......
<?php
class Doctrine_Export_Mysql_TestCase extends Doctrine_Export_TestCase {
class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
public function __construct() {
parent::__construct('mysql');
}
......
......@@ -4,7 +4,7 @@ class Doctrine_Export_TestCase extends Doctrine_Driver_UnitTestCase {
public function testCreateTableThrowsExceptionWithoutValidTableName() {
try {
$this->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) {
......
<?php
class Doctrine_Transaction_Pgsql_TestCase extends Doctrine_Driver_UnitTestCase {
class Doctrine_Transaction_Firebird_TestCase extends Doctrine_Driver_UnitTestCase {
public function __construct() {
parent::__construct('firebird');
}
......@@ -46,29 +46,29 @@ class Doctrine_Transaction_Pgsql_TestCase extends Doctrine_Driver_UnitTestCase {
$this->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');
}
}
<?php
class Doctrine_Transaction_Oracle_TestCase extends Doctrine_Driver_UnitTestCase {
class Doctrine_Transaction_Mssql_TestCase extends Doctrine_Driver_UnitTestCase {
public function __construct() {
parent::__construct('sqlite');
parent::__construct('mssql');
}
public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() {
try {
......
......@@ -30,9 +30,9 @@ class Doctrine_Transaction_Oracle_TestCase extends Doctrine_Driver_UnitTestCase
$this->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');
}
}
<?php
class Doctrine_Transaction_Oracle_TestCase extends Doctrine_Driver_UnitTestCase {
class Doctrine_Transaction_Sqlite_TestCase extends Doctrine_Driver_UnitTestCase {
public function __construct() {
parent::__construct('sqlite');
}
......@@ -15,11 +15,11 @@ class Doctrine_Transaction_Oracle_TestCase extends Doctrine_Driver_UnitTestCase
$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 = 0');
$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');
}
}
......@@ -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 '<pre>';
$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());
......
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