updated driver tests
This commit is contained in:
parent
41e5b46618
commit
01efe0ed22
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase {
|
class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase {
|
||||||
private $dict;
|
private $dict;
|
||||||
|
|
||||||
@ -59,4 +60,5 @@ class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertEqual($this->columns['col_real']->getName(), 'col_real');
|
$this->assertEqual($this->columns['col_real']->getName(), 'col_real');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
?>
|
?>
|
||||||
|
@ -66,23 +66,41 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase {
|
|||||||
protected $transaction;
|
protected $transaction;
|
||||||
|
|
||||||
public function __construct($driverName, $generic = false) {
|
public function __construct($driverName, $generic = false) {
|
||||||
|
|
||||||
$this->driverName = $driverName;
|
$this->driverName = $driverName;
|
||||||
$this->generic = $generic;
|
$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() {
|
public function init() {
|
||||||
$this->adapter = new AdapterMock($this->driverName);
|
$this->adapter = new AdapterMock($this->driverName);
|
||||||
$this->manager = Doctrine_Manager::getInstance();
|
$this->manager = Doctrine_Manager::getInstance();
|
||||||
$this->manager->setDefaultAttributes();
|
$this->manager->setDefaultAttributes();
|
||||||
$this->conn = $this->manager->openConnection($this->adapter);
|
$this->conn = $this->manager->openConnection($this->adapter);
|
||||||
|
|
||||||
if( ! $this->generic) {
|
if( ! $this->generic) {
|
||||||
$this->export = $this->conn->export;
|
$this->export = $this->conn->export;
|
||||||
|
|
||||||
|
$name = $this->adapter->getName();
|
||||||
|
|
||||||
if($this->adapter->getName() == 'oci')
|
if($this->adapter->getName() == 'oci')
|
||||||
$tx = 'Doctrine_Transaction_Oracle';
|
$name = 'Oracle';
|
||||||
else
|
|
||||||
$tx = 'Doctrine_Transaction_' . ucwords($this->adapter->getName());
|
$tx = 'Doctrine_Transaction_' . ucwords($name);
|
||||||
|
$dataDict = 'Doctrine_DataDict_' . ucwords($name);
|
||||||
|
|
||||||
if(class_exists($tx))
|
if(class_exists($tx))
|
||||||
$this->transaction = new $tx($this->conn);
|
$this->transaction = new $tx($this->conn);
|
||||||
|
if(class_exists($dataDict)) {
|
||||||
|
$this->dataDict = new $dataDict($this->conn);
|
||||||
|
}
|
||||||
//$this->dataDict = $this->conn->dataDict;
|
//$this->dataDict = $this->conn->dataDict;
|
||||||
} else {
|
} else {
|
||||||
$this->export = new Doctrine_Export($this->conn);
|
$this->export = new Doctrine_Export($this->conn);
|
||||||
|
@ -17,10 +17,21 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
|
|||||||
$name = 'mytable';
|
$name = 'mytable';
|
||||||
|
|
||||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1));
|
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1));
|
||||||
|
|
||||||
$options = array('type' => 'foo');
|
$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() {
|
public function testCreateDatabaseExecutesSql() {
|
||||||
$this->export->createDatabase('db');
|
$this->export->createDatabase('db');
|
||||||
@ -36,7 +47,8 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
|
|||||||
public function testDropIndexExecutesSql() {
|
public function testDropIndexExecutesSql() {
|
||||||
$this->export->dropIndex('sometable', 'relevancy');
|
$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