diff --git a/tests/DataDictSqliteTestCase.php b/tests/DataDictSqliteTestCase.php index 0c6ad934e..bd98122ec 100644 --- a/tests/DataDictSqliteTestCase.php +++ b/tests/DataDictSqliteTestCase.php @@ -1,4 +1,5 @@ assertEqual($this->columns['col_real']->getName(), 'col_real'); } } +*/ ?> diff --git a/tests/DriverTestCase.php b/tests/DriverTestCase.php index 6d128d479..faee7aee1 100644 --- a/tests/DriverTestCase.php +++ b/tests/DriverTestCase.php @@ -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); + $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); diff --git a/tests/ExportMysqlTestCase.php b/tests/ExportMysqlTestCase.php index 0f703bfb4..5baf166b9 100644 --- a/tests/ExportMysqlTestCase.php +++ b/tests/ExportMysqlTestCase.php @@ -16,11 +16,22 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase { public function testCreateTableExecutesSql() { $name = 'mytable'; - $fields = array('id' => array('type' => 'integer', 'unsigned' => 1)); - + $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'); @@ -35,8 +46,9 @@ 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'); } + } ?>