Commit 12d391fb authored by zYne's avatar zYne

new tests

parent d4fa4640
......@@ -13,10 +13,11 @@ class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase {
$name = 'mytable';
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true));
$options = array('primary' => array('id'));
$this->export->createTable($name, $fields, $options);
$this->export->createTable($name, $fields);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id SERIAL PRIMARY KEY)');
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id SERIAL, PRIMARY KEY(id))');
}
public function testCreateTableSupportsDefaultAttribute() {
$name = 'mytable';
......
......@@ -46,5 +46,50 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type INTEGER, PRIMARY KEY(name, type))');
}
public function testCreateTableSupportsIndexes()
{
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true, 'unique' => true),
'name' => array('type' => 'string', 'length' => 4),
);
$options = array('primary' => array('id'),
'indexes' => array('myindex' => array('fields' => array('id', 'name')))
);
$this->export->createTable('sometable', $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER UNSIGNED PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id, name))');
}
public function testUnknownIndexSortingAttributeThrowsException()
{
$fields = array('id' => array('sorting' => 'ASC'),
'name' => array('sorting' => 'unknown'));
try {
$this->export->getIndexFieldDeclarationList($fields);
$this->fail();
} catch(Doctrine_Export_Exception $e) {
$this->pass();
}
}
public function testCreateTableSupportsIndexesWithCustomSorting()
{
$fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true, 'unique' => true),
'name' => array('type' => 'string', 'length' => 4),
);
$options = array('primary' => array('id'),
'indexes' => array('myindex' => array(
'fields' => array(
'id' => array('sorting' => 'ASC'),
'name' => array('sorting' => 'DESC')
)
))
);
$this->export->createTable('sometable', $fields, $options);
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER UNSIGNED PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id ASC, name DESC))');
}
}
?>
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