2006-11-22 03:26:34 +03:00
|
|
|
<?php
|
2006-12-28 00:20:26 +03:00
|
|
|
class Doctrine_Export_TestCase extends Doctrine_UnitTestCase {
|
2006-11-22 03:26:34 +03:00
|
|
|
public function testCreateTableThrowsExceptionWithoutValidTableName() {
|
|
|
|
try {
|
2006-11-24 02:23:24 +03:00
|
|
|
$this->export->createTable(0, array(), array());
|
2006-11-22 03:26:34 +03:00
|
|
|
|
|
|
|
$this->fail();
|
|
|
|
} catch(Doctrine_Export_Exception $e) {
|
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testCreateTableThrowsExceptionWithEmptyFieldsArray() {
|
|
|
|
try {
|
2006-11-24 02:23:24 +03:00
|
|
|
$this->export->createTable('sometable', array(), array());
|
2006-11-22 03:26:34 +03:00
|
|
|
|
|
|
|
$this->fail();
|
|
|
|
} catch(Doctrine_Export_Exception $e) {
|
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
2006-11-23 02:35:34 +03:00
|
|
|
public function testDropConstraintExecutesSql() {
|
|
|
|
$this->export->dropConstraint('sometable', 'relevancy');
|
2006-12-28 00:20:26 +03:00
|
|
|
|
2006-11-29 02:26:44 +03:00
|
|
|
$this->assertEqual($this->adapter->pop(), 'ALTER TABLE sometable DROP CONSTRAINT relevancy_idx');
|
2006-11-23 02:35:34 +03:00
|
|
|
}
|
2006-11-22 03:26:34 +03:00
|
|
|
public function testCreateIndexExecutesSql() {
|
|
|
|
$this->export->createIndex('sometable', 'relevancy', array('fields' => array('title' => array(), 'content' => array())));
|
|
|
|
|
2006-12-28 00:20:26 +03:00
|
|
|
$this->assertEqual($this->adapter->pop(), 'CREATE INDEX relevancy_idx ON sometable (title, content)');
|
2006-11-22 03:26:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testDropIndexExecutesSql() {
|
|
|
|
$this->export->dropIndex('sometable', 'relevancy');
|
|
|
|
|
2006-11-29 02:26:44 +03:00
|
|
|
$this->assertEqual($this->adapter->pop(), 'DROP INDEX relevancy_idx');
|
2006-11-22 03:26:34 +03:00
|
|
|
}
|
|
|
|
public function testDropTableExecutesSql() {
|
|
|
|
$this->export->dropTable('sometable');
|
|
|
|
|
|
|
|
$this->assertEqual($this->adapter->pop(), 'DROP TABLE sometable');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|