Commit 9ed1eea1 authored by zYne's avatar zYne

More driver tests

parent 8162a684
...@@ -28,4 +28,95 @@ class Doctrine_DataDict_Pgsql_TestCase extends Doctrine_Driver_UnitTestCase { ...@@ -28,4 +28,95 @@ class Doctrine_DataDict_Pgsql_TestCase extends Doctrine_Driver_UnitTestCase {
$this->assertEqual($this->getDeclaration('boolean'), array(array('boolean'), 1, false, null)); $this->assertEqual($this->getDeclaration('boolean'), array(array('boolean'), 1, false, null));
} }
public function testGetNativeDefinitionSupportsIntegerType() {
$a = array('type' => 'integer', 'length' => 20, 'fixed' => false);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BIGINT');
$a['length'] = 4;
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INT');
$a['length'] = 2;
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'SMALLINT');
}
public function testGetNativeDefinitionSupportsIntegerTypeWithAutoinc() {
$a = array('type' => 'integer', 'length' => 20, 'fixed' => false, 'autoincrement' => true);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BIGSERIAL PRIMARY KEY');
$a['length'] = 4;
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'SERIAL PRIMARY KEY');
$a['length'] = 2;
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'SERIAL PRIMARY KEY');
}
public function testGetNativeDefinitionSupportsFloatType() {
$a = array('type' => 'float', 'length' => 20, 'fixed' => false);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'FLOAT8');
}
public function testGetNativeDefinitionSupportsBooleanType() {
$a = array('type' => 'boolean', 'fixed' => false);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BOOLEAN');
}
public function testGetNativeDefinitionSupportsDateType() {
$a = array('type' => 'date', 'fixed' => false);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'DATE');
}
public function testGetNativeDefinitionSupportsTimestampType() {
$a = array('type' => 'timestamp', 'fixed' => false);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TIMESTAMP without time zone');
}
public function testGetNativeDefinitionSupportsTimeType() {
$a = array('type' => 'time', 'fixed' => false);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TIME without time zone');
}
public function testGetNativeDefinitionSupportsClobType() {
$a = array('type' => 'clob');
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TEXT');
}
public function testGetNativeDefinitionSupportsBlobType() {
$a = array('type' => 'blob');
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'BYTEA');
}
public function testGetNativeDefinitionSupportsCharType() {
$a = array('type' => 'char', 'length' => 10);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CHAR(10)');
}
public function testGetNativeDefinitionSupportsVarcharType() {
$a = array('type' => 'varchar', 'length' => 10);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(10)');
}
public function testGetNativeDefinitionSupportsArrayType() {
$a = array('type' => 'array', 'length' => 40);
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR(40)');
}
public function testGetNativeDefinitionSupportsStringType() {
$a = array('type' => 'string');
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TEXT');
}
public function testGetNativeDefinitionSupportsArrayType2() {
$a = array('type' => 'array');
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TEXT');
}
public function testGetNativeDefinitionSupportsObjectType() {
$a = array('type' => 'object');
$this->assertEqual($this->dataDict->getNativeDeclaration($a), 'TEXT');
}
} }
...@@ -17,21 +17,92 @@ class Doctrine_Export_Mysql_TestCase extends Doctrine_Driver_UnitTestCase { ...@@ -17,21 +17,92 @@ 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' => 'MYISAM');
$this->export->createTable($name, $fields, $options); $this->export->createTable($name, $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT) ENGINE = foo'); $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT UNSIGNED) ENGINE = MYISAM');
} }
public function testCreateTableSupportsAutoincPks() { public function testCreateTableSupportsAutoincPks() {
$name = 'mytable'; $name = 'mytable';
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true)); $fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
$options = array('type' => 'foo'); $options = array('type' => 'INNODB');
$this->export->createTable($name, $fields, $options); $this->export->createTable($name, $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT) ENGINE = foo'); $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE = INNODB');
}
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');
}
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');
}
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');
}
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');
}
public function testCreateTableSupportsBlobType() {
$name = 'mytable';
$fields = array('content' => array('type' => 'blob'));
$options = array('type' => 'MYISAM');
$this->export->createTable($name, $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (content LONGBLOB) ENGINE = MYISAM');
}
public function testCreateTableSupportsBlobType2() {
$name = 'mytable';
$fields = array('content' => array('type' => 'blob', 'length' => 2000));
$options = array('type' => 'MYISAM');
$this->export->createTable($name, $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (content BLOB) ENGINE = MYISAM');
}
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');
} }
public function testCreateDatabaseExecutesSql() { public function testCreateDatabaseExecutesSql() {
$this->export->createDatabase('db'); $this->export->createDatabase('db');
......
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