Commit 94e5ce73 authored by zYne's avatar zYne

more tests

parent 9f42b875
......@@ -32,11 +32,6 @@
*/
class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
{
public function __construct()
{
parent::__construct('mysql');
}
public function testAlterTableThrowsExceptionWithoutValidTableName()
{
try {
......@@ -259,11 +254,12 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mysql_index_test_record (id BIGINT AUTO_INCREMENT, name TEXT, code INT, content TEXT, FULLTEXT INDEX content_idx (content), UNIQUE INDEX namecode_idx (name, code), PRIMARY KEY(id)) ENGINE = MYISAM');
}
public function testExportSupportsForeignKeys()
{
$r = new MysqlForeignKeyTest;
//print $this->adapter->pop();
//$this->assertEqual($this->adapter->pop());
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mysql_foreign_key_test (id BIGINT AUTO_INCREMENT, name TEXT, code INT, content TEXT, parent_id BIGINT, FOREIGN KEY id REFERENCES mysql_foreign_key_test(parent_id) ON UPDATE RESTRICT ON DELETE CASCADE, PRIMARY KEY(id)) ENGINE = INNODB');
}
}
class MysqlForeignKeyTest extends Doctrine_Record
......@@ -275,10 +271,10 @@ class MysqlForeignKeyTest extends Doctrine_Record
$this->hasColumn('content', 'string', 4000);
$this->hasColumn('parent_id', 'integer');
$this->foreignKey(array('local' => 'id',
'foreign' => 'parent_id',
'foreignTable' => 'mysql_foreign_key_test',
'onDelete' => 'CASCADE')
$this->hasMany('MysqlForeignKeyTest as Children',
'MysqlForeignKeyTest.parent_id',
array('onDelete' => 'CASCADE',
'onUpdate' => 'RESTRICT')
);
$this->option('type', 'INNODB');
......
......@@ -123,6 +123,19 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
$this->adapter->pop();
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id CHAR(3))');
}
public function testCreateTableSupportsUniqueConstraint()
{
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true, 'unique' => true),
'name' => array('type' => 'string', 'length' => 4),
);
$options = array('primary' => array('id'),
);
$sql = $this->export->createTableSql('sometable', $fields, $options);
$this->assertEqual($sql, 'CREATE TABLE sometable (id INT UNIQUE, name VARCHAR2(4), PRIMARY KEY(id))');
}
public function testCreateTableSupportsIndexes()
{
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true, 'unique' => true),
......@@ -133,9 +146,9 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
'indexes' => array('myindex' => array('fields' => array('id', 'name')))
);
$sql =$this->export->createTableSql('sometable', $fields, $options);
$sql = $this->export->createTableSql('sometable', $fields, $options);
$this->assertEqual($sql, 'CREATE TABLE sometable (id INTEGER UNSIGNED PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id, name))');
$this->assertEqual($sql, 'CREATE TABLE sometable (id INT UNIQUE, name VARCHAR2(4), PRIMARY KEY(id), INDEX myindex (id, name))');
}
}
?>
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