1
0
mirror of synced 2024-12-13 22:56:04 +03:00

more tests

This commit is contained in:
zYne 2007-02-17 11:09:34 +00:00
parent 9f42b87575
commit 94e5ce739a
2 changed files with 26 additions and 17 deletions

View File

@ -32,11 +32,6 @@
*/ */
class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
{ {
public function __construct()
{
parent::__construct('mysql');
}
public function testAlterTableThrowsExceptionWithoutValidTableName() public function testAlterTableThrowsExceptionWithoutValidTableName()
{ {
try { 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'); $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() public function testExportSupportsForeignKeys()
{ {
$r = new MysqlForeignKeyTest; $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 class MysqlForeignKeyTest extends Doctrine_Record
@ -275,10 +271,10 @@ class MysqlForeignKeyTest extends Doctrine_Record
$this->hasColumn('content', 'string', 4000); $this->hasColumn('content', 'string', 4000);
$this->hasColumn('parent_id', 'integer'); $this->hasColumn('parent_id', 'integer');
$this->foreignKey(array('local' => 'id', $this->hasMany('MysqlForeignKeyTest as Children',
'foreign' => 'parent_id', 'MysqlForeignKeyTest.parent_id',
'foreignTable' => 'mysql_foreign_key_test', array('onDelete' => 'CASCADE',
'onDelete' => 'CASCADE') 'onUpdate' => 'RESTRICT')
); );
$this->option('type', 'INNODB'); $this->option('type', 'INNODB');

View File

@ -123,6 +123,19 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
$this->adapter->pop(); $this->adapter->pop();
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id CHAR(3))'); $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() public function testCreateTableSupportsIndexes()
{ {
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true, 'unique' => true), $fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true, 'unique' => true),
@ -135,7 +148,7 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
$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))');
} }
} }
?> ?>