1
0
mirror of synced 2024-12-13 14:56:01 +03:00

updated driver tests

This commit is contained in:
zYne 2006-11-24 23:23:52 +00:00
parent 41e5b46618
commit 01efe0ed22
3 changed files with 41 additions and 9 deletions

View File

@ -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');
} }
} }
*/
?> ?>

View File

@ -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);

View File

@ -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');
} }
} }
?> ?>