- fixed tests to expect DEFAULT NULL when no default is specified on nullable non lob columns
This commit is contained in:
parent
88dfc98704
commit
982205b8fa
@ -30,9 +30,9 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Firebird_TestCase extends Doctrine_UnitTestCase
|
||||
class Doctrine_Export_Firebird_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
public function testCreateDatabaseDoesNotExecuteSql()
|
||||
public function testCreateDatabaseDoesNotExecuteSql()
|
||||
{
|
||||
try {
|
||||
$this->export->createDatabase('db');
|
||||
@ -41,7 +41,7 @@ class Doctrine_Export_Firebird_TestCase extends Doctrine_UnitTestCase
|
||||
$this->pass();
|
||||
}
|
||||
}
|
||||
public function testDropDatabaseDoesNotExecuteSql()
|
||||
public function testDropDatabaseDoesNotExecuteSql()
|
||||
{
|
||||
try {
|
||||
$this->export->dropDatabase('db');
|
||||
@ -50,37 +50,37 @@ class Doctrine_Export_Firebird_TestCase extends Doctrine_UnitTestCase
|
||||
$this->pass();
|
||||
}
|
||||
}
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
|
||||
|
||||
$this->export->createTable($name, $fields);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TRIGGER mytable_AUTOINCREMENT_PK FOR mytable ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF (NEW.id IS NULL OR NEW.id = 0) THEN NEW.id = GEN_ID(mytable_seq, 1) END');
|
||||
}
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10, 'default' => 'def'),
|
||||
'type' => array('type' => 'integer', 'length' => 3, 'default' => 12)
|
||||
);
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT \'def\', type INT DEFAULT 12, PRIMARY KEY(name, type))');
|
||||
}
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10),
|
||||
'type' => array('type' => 'integer', 'length' => 3));
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type INT, PRIMARY KEY(name, type))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT NULL, type INT DEFAULT NULL, PRIMARY KEY(name, type))');
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,11 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
public function prepareTables()
|
||||
public function prepareTables()
|
||||
{ }
|
||||
public function prepareData()
|
||||
public function prepareData()
|
||||
{ }
|
||||
|
||||
public function testAlterTableThrowsExceptionWithoutValidTableName()
|
||||
@ -47,99 +47,99 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
$this->pass();
|
||||
}
|
||||
}
|
||||
public function testCreateTableExecutesSql()
|
||||
public function testCreateTableExecutesSql()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT UNSIGNED) ENGINE = MYISAM');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT UNSIGNED DEFAULT NULL) ENGINE = MYISAM');
|
||||
}
|
||||
public function testCreateTableSupportsDefaultTableType()
|
||||
public function testCreateTableSupportsDefaultTableType()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1));
|
||||
|
||||
$this->export->createTable($name, $fields);
|
||||
|
||||
// INNODB is the default type
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT UNSIGNED) ENGINE = INNODB');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT UNSIGNED DEFAULT NULL) ENGINE = INNODB');
|
||||
}
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10),
|
||||
'type' => array('type' => 'integer', 'length' => 3));
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type MEDIUMINT, PRIMARY KEY(name, type)) ENGINE = INNODB');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT NULL, type MEDIUMINT DEFAULT NULL, PRIMARY KEY(name, type)) ENGINE = INNODB');
|
||||
}
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
|
||||
$options = array('primary' => array('id'),
|
||||
$options = array('primary' => array('id'),
|
||||
'type' => 'INNODB');
|
||||
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
}
|
||||
public function testCreateTableSupportsCharType()
|
||||
public function testCreateTableSupportsCharType()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'char', 'length' => 3));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id CHAR(3)) ENGINE = MYISAM');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id CHAR(3) DEFAULT NULL) ENGINE = MYISAM');
|
||||
}
|
||||
public function testCreateTableSupportsCharType2()
|
||||
public function testCreateTableSupportsCharType2()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'char'));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id CHAR(255)) ENGINE = MYISAM');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id CHAR(255) DEFAULT NULL) ENGINE = MYISAM');
|
||||
}
|
||||
public function testCreateTableSupportsVarcharType()
|
||||
public function testCreateTableSupportsVarcharType()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'varchar', 'length' => '100'));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id VARCHAR(100)) ENGINE = MYISAM');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id VARCHAR(100) DEFAULT NULL) ENGINE = MYISAM');
|
||||
}
|
||||
public function testCreateTableSupportsIntegerType()
|
||||
public function testCreateTableSupportsIntegerType()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'length' => '10'));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id BIGINT) ENGINE = MYISAM');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id BIGINT DEFAULT NULL) ENGINE = MYISAM');
|
||||
}
|
||||
public function testCreateTableSupportsBlobType()
|
||||
public function testCreateTableSupportsBlobType()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('content' => array('type' => 'blob'));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
@ -147,10 +147,10 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (content LONGBLOB) ENGINE = MYISAM');
|
||||
}
|
||||
public function testCreateTableSupportsBlobType2()
|
||||
public function testCreateTableSupportsBlobType2()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('content' => array('type' => 'blob', 'length' => 2000));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
@ -162,18 +162,18 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
public function testCreateTableSupportsBooleanType()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'boolean'));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id TINYINT(1)) ENGINE = MYISAM');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id TINYINT(1) DEFAULT NULL) ENGINE = MYISAM');
|
||||
}
|
||||
public function testCreateTableSupportsForeignKeys()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'boolean', 'primary' => true),
|
||||
'foreignKey' => array('type' => 'integer')
|
||||
);
|
||||
@ -186,7 +186,7 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$sql = $this->export->createTableSql($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mytable (id TINYINT(1), foreignKey INT, INDEX foreignKey_idx (foreignKey)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mytable (id TINYINT(1) DEFAULT NULL, foreignKey INT DEFAULT NULL, INDEX foreignKey_idx (foreignKey)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[1], 'ALTER TABLE mytable ADD FOREIGN KEY (foreignKey) REFERENCES sometable(id)');
|
||||
}
|
||||
public function testForeignKeyIdentifierQuoting()
|
||||
@ -207,7 +207,7 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$sql = $this->export->createTableSql($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE `mytable` (`id` TINYINT(1), `foreignKey` INT, INDEX `foreignKey_idx` (`foreignKey`)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE `mytable` (`id` TINYINT(1) DEFAULT NULL, `foreignKey` INT DEFAULT NULL, INDEX `foreignKey_idx` (`foreignKey`)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[1], 'ALTER TABLE `mytable` ADD FOREIGN KEY (`foreignKey`) REFERENCES `sometable`(`id`)');
|
||||
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false);
|
||||
@ -226,18 +226,18 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
|
||||
//this was the old line, but it looks like the table is created first
|
||||
//this was the old line, but it looks like the table is created first
|
||||
//and then the index so i replaced it with the ones below
|
||||
//$this->assertEqual($var, 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id, name))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE `sometable` (`id` INT UNSIGNED AUTO_INCREMENT, `name` VARCHAR(4), INDEX `myindex_idx` (`id`, `name`), PRIMARY KEY(`id`)) ENGINE = INNODB');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE `sometable` (`id` INT UNSIGNED AUTO_INCREMENT, `name` VARCHAR(4) DEFAULT NULL, INDEX `myindex_idx` (`id`, `name`), PRIMARY KEY(`id`)) ENGINE = INNODB');
|
||||
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false);
|
||||
}
|
||||
public function testCreateTableDoesNotAutoAddIndexesWhenIndexForFkFieldAlreadyExists()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'boolean', 'primary' => true),
|
||||
'foreignKey' => array('type' => 'integer')
|
||||
);
|
||||
@ -250,7 +250,7 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
|
||||
$sql = $this->export->createTableSql($name, $fields, $options);
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mytable (id TINYINT(1), foreignKey INT, INDEX myindex_idx (foreignKey)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mytable (id TINYINT(1) DEFAULT NULL, foreignKey INT DEFAULT NULL, INDEX myindex_idx (foreignKey)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[1], 'ALTER TABLE mytable ADD FOREIGN KEY (foreignKey) REFERENCES sometable(id)');
|
||||
}
|
||||
public function testCreateDatabaseExecutesSql()
|
||||
@ -259,14 +259,14 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE DATABASE db');
|
||||
}
|
||||
public function testDropDatabaseExecutesSql()
|
||||
public function testDropDatabaseExecutesSql()
|
||||
{
|
||||
$this->export->dropDatabase('db');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'DROP DATABASE db');
|
||||
}
|
||||
|
||||
public function testDropIndexExecutesSql()
|
||||
public function testDropIndexExecutesSql()
|
||||
{
|
||||
$this->export->dropIndex('sometable', 'relevancy');
|
||||
|
||||
@ -302,8 +302,8 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
'fields' => 'name'))
|
||||
);
|
||||
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INT UNSIGNED AUTO_INCREMENT, name VARCHAR(4), INDEX myindex_idx (name), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INT UNSIGNED AUTO_INCREMENT, name VARCHAR(4) DEFAULT NULL, INDEX myindex_idx (name), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
}
|
||||
public function testCreateTableSupportsIndexesWithCustomSorting()
|
||||
{
|
||||
@ -314,15 +314,15 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
$options = array('primary' => array('id'),
|
||||
'indexes' => array('myindex' => array(
|
||||
'fields' => array(
|
||||
'id' => array('sorting' => 'ASC'),
|
||||
'id' => array('sorting' => 'ASC'),
|
||||
'name' => array('sorting' => 'DESC')
|
||||
)
|
||||
))
|
||||
);
|
||||
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INT UNSIGNED AUTO_INCREMENT, name VARCHAR(4), INDEX myindex_idx (id ASC, name DESC), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INT UNSIGNED AUTO_INCREMENT, name VARCHAR(4) DEFAULT NULL, INDEX myindex_idx (id ASC, name DESC), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
}
|
||||
public function testCreateTableSupportsFulltextIndexes()
|
||||
{
|
||||
@ -341,7 +341,7 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_UnitTestCase
|
||||
);
|
||||
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INT UNSIGNED AUTO_INCREMENT, content VARCHAR(4), FULLTEXT INDEX myindex_idx (content DESC), PRIMARY KEY(id)) ENGINE = MYISAM');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INT UNSIGNED AUTO_INCREMENT, content VARCHAR(4) DEFAULT NULL, FULLTEXT INDEX myindex_idx (content DESC), PRIMARY KEY(id)) ENGINE = MYISAM');
|
||||
}
|
||||
}
|
||||
|
@ -30,75 +30,75 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
|
||||
class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
public function testCreateSequenceExecutesSql()
|
||||
public function testCreateSequenceExecutesSql()
|
||||
{
|
||||
$sequenceName = 'sequence';
|
||||
$start = 1;
|
||||
$query = 'CREATE SEQUENCE ' . $sequenceName . '_seq START WITH ' . $start . ' INCREMENT BY 1 NOCACHE';
|
||||
|
||||
$this->export->createSequence($sequenceName, $start);
|
||||
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), $query);
|
||||
}
|
||||
|
||||
public function testDropSequenceExecutesSql()
|
||||
public function testDropSequenceExecutesSql()
|
||||
{
|
||||
$sequenceName = 'sequence';
|
||||
|
||||
$query = 'DROP SEQUENCE ' . $sequenceName;
|
||||
|
||||
$this->export->dropSequence($sequenceName);
|
||||
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), $query . '_seq');
|
||||
}
|
||||
public function testCreateTableExecutesSql()
|
||||
public function testCreateTableExecutesSql()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer'));
|
||||
$options = array('type' => 'MYISAM');
|
||||
|
||||
|
||||
$this->export->createTable($name, $fields);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'COMMIT');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT)');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT DEFAULT NULL)');
|
||||
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
|
||||
}
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10, 'default' => 'def'),
|
||||
'type' => array('type' => 'integer', 'length' => 3, 'default' => 12)
|
||||
);
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'COMMIT');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT \'def\', type NUMBER(3) DEFAULT 12, PRIMARY KEY(name, type))');
|
||||
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
|
||||
}
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10),
|
||||
'type' => array('type' => 'integer', 'length' => 3));
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'COMMIT');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type NUMBER(3), PRIMARY KEY(name, type))');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT NULL, type NUMBER(3) DEFAULT NULL, PRIMARY KEY(name, type))');
|
||||
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
|
||||
}
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'autoincrement' => true));
|
||||
|
||||
|
||||
@ -106,22 +106,22 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'COMMIT');
|
||||
$this->assertEqual(substr($this->adapter->pop(),0, 14), 'CREATE TRIGGER');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE SEQUENCE MYTABLE_seq START WITH 1 INCREMENT BY 1 NOCACHE');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE SEQUENCE MYTABLE_seq START WITH 1 INCREMENT BY 1 NOCACHE');
|
||||
$this->assertEqual($this->adapter->pop(), 'ALTER TABLE MYTABLE ADD CONSTRAINT MYTABLE_AI_PK_idx PRIMARY KEY (id)');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT)');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT DEFAULT NULL)');
|
||||
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
|
||||
}
|
||||
|
||||
public function testCreateTableSupportsCharType()
|
||||
public function testCreateTableSupportsCharType()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'char', 'length' => 3));
|
||||
|
||||
$this->export->createTable($name, $fields);
|
||||
|
||||
$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) DEFAULT NULL)');
|
||||
}
|
||||
public function testCreateTableSupportsUniqueConstraint()
|
||||
{
|
||||
@ -134,7 +134,7 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$sql = $this->export->createTableSql('sometable', $fields, $options);
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE sometable (id INT UNIQUE, name VARCHAR2(4), PRIMARY KEY(id))');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE sometable (id INT DEFAULT NULL UNIQUE, name VARCHAR2(4) DEFAULT NULL, PRIMARY KEY(id))');
|
||||
}
|
||||
public function testCreateTableSupportsIndexes()
|
||||
{
|
||||
@ -148,6 +148,6 @@ class Doctrine_Export_Oracle_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$sql = $this->export->createTableSql('sometable', $fields, $options);
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE sometable (id INT UNIQUE, name VARCHAR2(4), PRIMARY KEY(id), INDEX myindex (id, name))');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE sometable (id INT DEFAULT NULL UNIQUE, name VARCHAR2(4) DEFAULT NULL, PRIMARY KEY(id), INDEX myindex (id, name))');
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,9 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase
|
||||
class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
public function testCreateDatabaseExecutesSql()
|
||||
public function testCreateDatabaseExecutesSql()
|
||||
{
|
||||
$this->export->createDatabase('db');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE DATABASE db');
|
||||
@ -43,18 +43,18 @@ class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'DROP DATABASE db');
|
||||
}
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
|
||||
$options = array('primary' => array('id'));
|
||||
|
||||
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id SERIAL, PRIMARY KEY(id))');
|
||||
}
|
||||
public function testQuoteAutoincPks()
|
||||
public function testQuoteAutoincPks()
|
||||
{
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
|
||||
|
||||
@ -74,7 +74,7 @@ class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE "mytable" ("name" CHAR(10), "type" INT, PRIMARY KEY("name", "type"))');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE "mytable" ("name" CHAR(10) DEFAULT NULL, "type" INT, PRIMARY KEY("name", "type"))');
|
||||
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false);
|
||||
}
|
||||
@ -95,18 +95,18 @@ class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$sql = $this->export->createTableSql($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE "mytable" ("id" BOOLEAN, "foreignKey" INT)');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE "mytable" ("id" BOOLEAN DEFAULT NULL, "foreignKey" INT)');
|
||||
$this->assertEqual($sql[1], 'ALTER TABLE "mytable" ADD FOREIGN KEY ("foreignKey") REFERENCES "sometable"("id") NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false);
|
||||
}
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10, 'default' => 'def'),
|
||||
'type' => array('type' => 'integer', 'length' => 3, 'default' => 12)
|
||||
);
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
@ -117,28 +117,28 @@ class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10),
|
||||
'type' => array('type' => 'integer', 'length' => 3));
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type INT, PRIMARY KEY(name, type))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT NULL, type INT, PRIMARY KEY(name, type))');
|
||||
}
|
||||
public function testExportSql()
|
||||
{
|
||||
$sql = $this->export->exportClassesSql(array("FooRecord", "FooReferenceRecord", "FooLocallyOwned", "FooForeignlyOwned", "FooForeignlyOwnedWithPK", "FooBarRecord", "BarRecord"));
|
||||
//dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files');
|
||||
|
||||
$this->assertEqual($sql, array ( 0 => 'CREATE TABLE foo_reference (foo1 BIGINT, foo2 BIGINT, PRIMARY KEY(foo1, foo2))',
|
||||
1 => 'CREATE TABLE foo_locally_owned (id BIGSERIAL, name VARCHAR(200), PRIMARY KEY(id))',
|
||||
2 => 'CREATE TABLE foo_foreignly_owned_with_pk (id BIGSERIAL, name VARCHAR(200), PRIMARY KEY(id))',
|
||||
3 => 'CREATE TABLE foo_foreignly_owned (id BIGSERIAL, name VARCHAR(200), fooid BIGINT, PRIMARY KEY(id))',
|
||||
4 => 'CREATE TABLE foo_bar_record (fooid BIGINT, barid BIGINT, PRIMARY KEY(fooid, barid))',
|
||||
5 => 'CREATE TABLE foo (id BIGSERIAL, name VARCHAR(200) NOT NULL, parent_id BIGINT, local_foo BIGINT, PRIMARY KEY(id))',
|
||||
6 => 'CREATE TABLE bar (id BIGSERIAL, name VARCHAR(200), PRIMARY KEY(id))',
|
||||
7 => 'ALTER TABLE foo_reference ADD FOREIGN KEY (foo1) REFERENCES foo(id) NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
8 => 'ALTER TABLE foo_bar_record ADD FOREIGN KEY (fooId) REFERENCES foo(id) NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
9 => 'ALTER TABLE foo ADD FOREIGN KEY (parent_id) REFERENCES foo(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
10 => 'ALTER TABLE foo ADD FOREIGN KEY (local_foo) REFERENCES foo_locally_owned(id) ON DELETE RESTRICT NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
$this->assertEqual($sql, array ( 0 => 'CREATE TABLE foo_reference (foo1 BIGINT, foo2 BIGINT, PRIMARY KEY(foo1, foo2))',
|
||||
1 => 'CREATE TABLE foo_locally_owned (id BIGSERIAL, name VARCHAR(200) DEFAULT NULL, PRIMARY KEY(id))',
|
||||
2 => 'CREATE TABLE foo_foreignly_owned_with_pk (id BIGSERIAL, name VARCHAR(200) DEFAULT NULL, PRIMARY KEY(id))',
|
||||
3 => 'CREATE TABLE foo_foreignly_owned (id BIGSERIAL, name VARCHAR(200) DEFAULT NULL, fooid BIGINT, PRIMARY KEY(id))',
|
||||
4 => 'CREATE TABLE foo_bar_record (fooid BIGINT, barid BIGINT, PRIMARY KEY(fooid, barid))',
|
||||
5 => 'CREATE TABLE foo (id BIGSERIAL, name VARCHAR(200) NOT NULL, parent_id BIGINT, local_foo BIGINT, PRIMARY KEY(id))',
|
||||
6 => 'CREATE TABLE bar (id BIGSERIAL, name VARCHAR(200) DEFAULT NULL, PRIMARY KEY(id))',
|
||||
7 => 'ALTER TABLE foo_reference ADD FOREIGN KEY (foo1) REFERENCES foo(id) NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
8 => 'ALTER TABLE foo_bar_record ADD FOREIGN KEY (fooId) REFERENCES foo(id) NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
9 => 'ALTER TABLE foo ADD FOREIGN KEY (parent_id) REFERENCES foo(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
10 => 'ALTER TABLE foo ADD FOREIGN KEY (local_foo) REFERENCES foo_locally_owned(id) ON DELETE RESTRICT NOT DEFERRABLE INITIALLY IMMEDIATE',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -32,9 +32,9 @@
|
||||
*/
|
||||
class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
public function prepareTables()
|
||||
public function prepareTables()
|
||||
{ }
|
||||
public function prepareData()
|
||||
public function prepareData()
|
||||
{ }
|
||||
public function setUp() {
|
||||
$this->driverName = 'mysql';
|
||||
@ -49,7 +49,7 @@ class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
$sql = $this->conn->export->exportClassesSql(array('ForeignKeyTest'));
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE foreign_key_test (id BIGINT AUTO_INCREMENT, name TEXT, code INT, content TEXT, parent_id BIGINT, INDEX parent_id_idx (parent_id), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE foreign_key_test (id BIGINT AUTO_INCREMENT, name TEXT DEFAULT NULL, code INT DEFAULT NULL, content TEXT DEFAULT NULL, parent_id BIGINT DEFAULT NULL, INDEX parent_id_idx (parent_id), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
if (isset($sql[1])) {
|
||||
$this->assertEqual($sql[1], 'ALTER TABLE foreign_key_test ADD FOREIGN KEY (parent_id) REFERENCES foreign_key_test(id) ON UPDATE RESTRICT ON DELETE CASCADE');
|
||||
} else {
|
||||
@ -61,21 +61,21 @@ class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
$sql = $this->conn->export->exportClassesSql(array('MysqlIndexTestRecord'));
|
||||
|
||||
$this->assertEqual($sql[0], '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($sql[0], 'CREATE TABLE mysql_index_test_record (id BIGINT AUTO_INCREMENT, name TEXT DEFAULT NULL, code INT DEFAULT NULL, content TEXT DEFAULT NULL, FULLTEXT INDEX content_idx (content), UNIQUE INDEX namecode_idx (name, code), PRIMARY KEY(id)) ENGINE = MYISAM');
|
||||
}
|
||||
|
||||
public function testRecordDefinitionsSupportTableOptions()
|
||||
{
|
||||
$sql = $this->conn->export->exportClassesSql(array('MysqlTestRecord'));
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mysql_test_record (name TEXT, code BIGINT, PRIMARY KEY(name, code)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mysql_test_record (name TEXT DEFAULT NULL, code BIGINT DEFAULT NULL, PRIMARY KEY(name, code)) ENGINE = INNODB');
|
||||
}
|
||||
|
||||
public function testExportSupportsForeignKeysWithoutAttributes()
|
||||
{
|
||||
$sql = $this->conn->export->exportClassesSql(array('ForeignKeyTest'));
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE foreign_key_test (id BIGINT AUTO_INCREMENT, name TEXT, code INT, content TEXT, parent_id BIGINT, INDEX parent_id_idx (parent_id), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE foreign_key_test (id BIGINT AUTO_INCREMENT, name TEXT DEFAULT NULL, code INT DEFAULT NULL, content TEXT DEFAULT NULL, parent_id BIGINT DEFAULT NULL, INDEX parent_id_idx (parent_id), PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
if (isset($sql[1])) {
|
||||
$this->assertEqual($sql[1], 'ALTER TABLE foreign_key_test ADD FOREIGN KEY (parent_id) REFERENCES foreign_key_test(id) ON UPDATE RESTRICT ON DELETE CASCADE');
|
||||
} else {
|
||||
@ -87,25 +87,20 @@ class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
$sql = $this->conn->export->exportClassesSql(array('MysqlUser'));
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mysql_user (id BIGINT AUTO_INCREMENT, name TEXT, PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mysql_user (id BIGINT AUTO_INCREMENT, name TEXT DEFAULT NULL, PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
|
||||
$sql = $this->conn->export->exportClassesSql(array('MysqlGroup'));
|
||||
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mysql_group (id BIGINT AUTO_INCREMENT, name TEXT, PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
$this->assertEqual($sql[0], 'CREATE TABLE mysql_group (id BIGINT AUTO_INCREMENT, name TEXT DEFAULT NULL, PRIMARY KEY(id)) ENGINE = INNODB');
|
||||
}
|
||||
|
||||
public function testExportModelFromDirectory()
|
||||
{
|
||||
|
||||
Doctrine::createTablesFromModels(dirname(__FILE__) . DIRECTORY_SEPARATOR .'..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'export');
|
||||
$this->assertEqual($this->adapter->pop(), 'COMMIT');
|
||||
$this->assertEqual($this->adapter->pop(), 'ALTER TABLE cms__category_languages ADD FOREIGN KEY (category_id) REFERENCES cms__category(id) ON DELETE CASCADE');
|
||||
$createTableSql = array(
|
||||
'CREATE TABLE cms__category_languages (id BIGINT AUTO_INCREMENT, name TEXT, category_id BIGINT, language_id BIGINT, INDEX index_category_idx (category_id), INDEX index_language_idx (language_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB',
|
||||
'CREATE TABLE cms__category (id BIGINT AUTO_INCREMENT, created DATETIME, parent BIGINT, position MEDIUMINT, active BIGINT, INDEX index_parent_idx (parent), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB'
|
||||
);
|
||||
$this->assertTrue(in_array($this->adapter->pop(), $createTableSql));
|
||||
$this->assertTrue(in_array($this->adapter->pop(), $createTableSql));
|
||||
$this->assertTrue($this->adapter->pop(), 'CREATE TABLE cms__category_languages (id BIGINT AUTO_INCREMENT, name TEXT DEFAULT NULL, category_id BIGINT DEFAULT NULL, language_id BIGINT DEFAULT NULL, INDEX index_category_idx (category_id), INDEX index_language_idx (language_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
|
||||
$this->assertTrue($this->adapter->pop(), 'CREATE TABLE cms__category (id BIGINT AUTO_INCREMENT, created DATETIME DEFAULT NULL, parent BIGINT DEFAULT NULL, position MEDIUMINT DEFAULT NULL, active BIGINT DEFAULT NULL, INDEX index_parent_idx (parent), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
|
||||
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
public function testCreateDatabaseDoesNotExecuteSql()
|
||||
public function testCreateDatabaseDoesNotExecuteSql()
|
||||
{
|
||||
try {
|
||||
$this->export->createDatabase('db');
|
||||
@ -41,7 +41,7 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
$this->pass();
|
||||
}
|
||||
}
|
||||
public function testDropDatabaseDoesNotExecuteSql()
|
||||
public function testDropDatabaseDoesNotExecuteSql()
|
||||
{
|
||||
try {
|
||||
$this->export->dropDatabase('db');
|
||||
@ -50,17 +50,17 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
$this->pass();
|
||||
}
|
||||
}
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
public function testCreateTableSupportsAutoincPks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
|
||||
|
||||
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
|
||||
|
||||
$this->export->createTable($name, $fields);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INTEGER PRIMARY KEY AUTOINCREMENT)');
|
||||
}
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
public function testCreateTableSupportsDefaultAttribute()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10, 'default' => 'def'),
|
||||
@ -72,16 +72,16 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT \'def\', type INTEGER DEFAULT 12, PRIMARY KEY(name, type))');
|
||||
}
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
public function testCreateTableSupportsMultiplePks()
|
||||
{
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10),
|
||||
'type' => array('type' => 'integer', 'length' => 3));
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type INTEGER, PRIMARY KEY(name, type))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT NULL, type INTEGER, PRIMARY KEY(name, type))');
|
||||
}
|
||||
public function testCreateTableSupportsIndexes()
|
||||
{
|
||||
@ -95,13 +95,13 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
|
||||
//this was the old line, but it looks like the table is created first
|
||||
//this was the old line, but it looks like the table is created first
|
||||
//and then the index so i replaced it with the ones below
|
||||
//$this->assertEqual($var, 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id, name))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(),"CREATE INDEX myindex_idx ON sometable (id, name)");
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4))');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4) DEFAULT NULL)');
|
||||
}
|
||||
public function testIdentifierQuoting()
|
||||
{
|
||||
@ -117,28 +117,28 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
|
||||
//this was the old line, but it looks like the table is created first
|
||||
//this was the old line, but it looks like the table is created first
|
||||
//and then the index so i replaced it with the ones below
|
||||
//$this->assertEqual($var, 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id, name))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(),'CREATE INDEX "myindex_idx" ON "sometable" ("id", "name")');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE "sometable" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(4))');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE "sometable" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(4) DEFAULT NULL)');
|
||||
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false);
|
||||
}
|
||||
public function testQuoteMultiplePks()
|
||||
public function testQuoteMultiplePks()
|
||||
{
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
|
||||
|
||||
$name = 'mytable';
|
||||
$fields = array('name' => array('type' => 'char', 'length' => 10),
|
||||
'type' => array('type' => 'integer', 'length' => 3));
|
||||
|
||||
|
||||
$options = array('primary' => array('name', 'type'));
|
||||
$this->export->createTable($name, $fields, $options);
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE "mytable" ("name" CHAR(10), "type" INTEGER, PRIMARY KEY("name", "type"))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE "mytable" ("name" CHAR(10) DEFAULT NULL, "type" INTEGER, PRIMARY KEY("name", "type"))');
|
||||
|
||||
$this->conn->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, false);
|
||||
}
|
||||
@ -163,20 +163,20 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase
|
||||
$options = array('primary' => array('id'),
|
||||
'indexes' => array('myindex' => array(
|
||||
'fields' => array(
|
||||
'id' => array('sorting' => 'ASC'),
|
||||
'id' => array('sorting' => 'ASC'),
|
||||
'name' => array('sorting' => 'DESC')
|
||||
)
|
||||
))
|
||||
);
|
||||
|
||||
$this->export->createTable('sometable', $fields, $options);
|
||||
|
||||
|
||||
//removed this assertion and inserted the two below
|
||||
// $this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id ASC, name DESC))');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(),"CREATE INDEX myindex_idx ON sometable (id ASC, name DESC)");
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4))');
|
||||
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4) DEFAULT NULL)');
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user