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

new tests

This commit is contained in:
zYne 2007-02-10 20:48:45 +00:00
parent d4fa4640cb
commit 12d391fb42
2 changed files with 49 additions and 3 deletions

View File

@ -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);
$this->export->createTable($name, $fields, $options);
$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';

View File

@ -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))');
}
}
?>