ExportTestCase.php 1.56 KB
Newer Older
1
<?php
zYne's avatar
zYne committed
2
class Doctrine_Export_TestCase extends Doctrine_UnitTestCase {
3 4
    public function testCreateTableThrowsExceptionWithoutValidTableName() {
        try {
zYne's avatar
zYne committed
5
            $this->export->createTable(0, array(), array());
6 7 8 9 10 11 12 13

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

            $this->fail();
        } catch(Doctrine_Export_Exception $e) {
            $this->pass();
        }
    }
zYne's avatar
zYne committed
21 22
    public function testDropConstraintExecutesSql() {
        $this->export->dropConstraint('sometable', 'relevancy');
zYne's avatar
zYne committed
23

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

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