updated driver tests
This commit is contained in:
parent
41e5b46618
commit
01efe0ed22
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase {
|
||||
private $dict;
|
||||
|
||||
@ -59,4 +60,5 @@ class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertEqual($this->columns['col_real']->getName(), 'col_real');
|
||||
}
|
||||
}
|
||||
*/
|
||||
?>
|
||||
|
@ -66,23 +66,41 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase {
|
||||
protected $transaction;
|
||||
|
||||
public function __construct($driverName, $generic = false) {
|
||||
|
||||
$this->driverName = $driverName;
|
||||
$this->generic = $generic;
|
||||
}
|
||||
public function assertDeclarationType($type, $type2) {
|
||||
$dec = $this->getDeclaration($type);
|
||||
if( ! is_array($type2))
|
||||
$type2 = array($type2);
|
||||
$this->assertEqual($dec[0], $type2);
|
||||
}
|
||||
public function getDeclaration($type) {
|
||||
return $this->dataDict->getDoctrineDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 1, 'fixed' => true));
|
||||
}
|
||||
public function init() {
|
||||
$this->adapter = new AdapterMock($this->driverName);
|
||||
$this->manager = Doctrine_Manager::getInstance();
|
||||
$this->manager->setDefaultAttributes();
|
||||
$this->conn = $this->manager->openConnection($this->adapter);
|
||||
|
||||
if( ! $this->generic) {
|
||||
$this->export = $this->conn->export;
|
||||
|
||||
$name = $this->adapter->getName();
|
||||
|
||||
if($this->adapter->getName() == 'oci')
|
||||
$tx = 'Doctrine_Transaction_Oracle';
|
||||
else
|
||||
$tx = 'Doctrine_Transaction_' . ucwords($this->adapter->getName());
|
||||
$name = 'Oracle';
|
||||
|
||||
$tx = 'Doctrine_Transaction_' . ucwords($name);
|
||||
$dataDict = 'Doctrine_DataDict_' . ucwords($name);
|
||||
|
||||
if(class_exists($tx))
|
||||
$this->transaction = new $tx($this->conn);
|
||||
if(class_exists($dataDict)) {
|
||||
$this->dataDict = new $dataDict($this->conn);
|
||||
}
|
||||
//$this->dataDict = $this->conn->dataDict;
|
||||
} else {
|
||||
$this->export = new Doctrine_Export($this->conn);
|
||||
|
@ -17,10 +17,21 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
|
||||
$name = 'mytable';
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1));
|
||||
|
||||
$options = array('type' => 'foo');
|
||||
|
||||
//$this->export->createTable($name, $fields, $options);
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT) ENGINE = foo');
|
||||
}
|
||||
public function testCreateTableSupportsAutoincPks() {
|
||||
$name = 'mytable';
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
|
||||
$options = array('type' => 'foo');
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT) ENGINE = foo');
|
||||
}
|
||||
public function testCreateDatabaseExecutesSql() {
|
||||
$this->export->createDatabase('db');
|
||||
@ -36,7 +47,8 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
|
||||
public function testDropIndexExecutesSql() {
|
||||
$this->export->dropIndex('sometable', 'relevancy');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'DROP INDEX relevancy ON sometable');
|
||||
$this->assertEqual($this->adapter->pop(), 'DROP INDEX relevancy_idx ON sometable');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user