ExportTestCase.php 1.57 KB
Newer Older
1 2 3 4 5 6
<?php
class Doctrine_Export_TestCase extends Doctrine_Driver_UnitTestCase {


    public function testCreateTableThrowsExceptionWithoutValidTableName() {
        try {
zYne's avatar
zYne committed
7
            $this->export->createTable(0, array(), array());
8 9 10 11 12 13 14 15

            $this->fail();
        } catch(Doctrine_Export_Exception $e) {
            $this->pass();
        }
    }
    public function testCreateTableThrowsExceptionWithEmptyFieldsArray() {
        try {
zYne's avatar
zYne committed
16
            $this->export->createTable('sometable', array(), array());
17 18 19 20 21 22

            $this->fail();
        } catch(Doctrine_Export_Exception $e) {
            $this->pass();
        }
    }
zYne's avatar
zYne committed
23 24 25
    public function testDropConstraintExecutesSql() {
        $this->export->dropConstraint('sometable', 'relevancy');
        
26
        $this->assertEqual($this->adapter->pop(), 'ALTER TABLE sometable DROP CONSTRAINT relevancy_idx');
zYne's avatar
zYne committed
27
    }
28 29 30 31 32 33 34 35 36
    public function testCreateIndexExecutesSql() {
        $this->export->createIndex('sometable', 'relevancy', array('fields' => array('title' => array(), 'content' => array())));
        
        $this->assertEqual($this->adapter->pop(), 'CREATE INDEX relevancy ON sometable (title, content)');
    }

    public function testDropIndexExecutesSql() {
        $this->export->dropIndex('sometable', 'relevancy');
        
37
        $this->assertEqual($this->adapter->pop(), 'DROP INDEX relevancy_idx');
38 39 40 41 42 43 44 45
    }
    public function testDropTableExecutesSql() {
        $this->export->dropTable('sometable');
        
        $this->assertEqual($this->adapter->pop(), 'DROP TABLE sometable');
    }
}
?>