TransactionFirebirdTestCase.php 3.38 KB
Newer Older
1
<?php
zYne's avatar
zYne committed
2
class Doctrine_Transaction_Firebird_TestCase extends Doctrine_Driver_UnitTestCase {
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
    public function __construct() {
        parent::__construct('firebird');
    }
    public function testCreateSavePointExecutesSql() {
        $this->transaction->createSavePoint('mypoint');
        
        $this->assertEqual($this->adapter->pop(), 'SAVEPOINT mypoint');
    }
    public function testReleaseSavePointExecutesSql() {
        $this->transaction->releaseSavePoint('mypoint');

        $this->assertEqual($this->adapter->pop(), 'RELEASE SAVEPOINT mypoint');
    }
    public function testRollbackSavePointExecutesSql() {
        $this->transaction->rollbackSavePoint('mypoint');

        $this->assertEqual($this->adapter->pop(), 'ROLLBACK TO SAVEPOINT mypoint');
    }
    public function testSetIsolationThrowsExceptionOnUnknownIsolationMode() {
        try {
            $this->transaction->setIsolation('unknown');
            $this->fail();
        } catch(Doctrine_Transaction_Exception $e) {
            $this->pass();
        }
    }
    public function testSetIsolationThrowsExceptionOnUnknownWaitMode() {
        try {
            $this->transaction->setIsolation('READ UNCOMMITTED', array('wait' => 'unknown'));
            $this->fail();
        } catch(Doctrine_Transaction_Exception $e) {
            $this->pass();
        }
    }
    public function testSetIsolationThrowsExceptionOnUnknownReadWriteMode() {
        try {
            $this->transaction->setIsolation('READ UNCOMMITTED', array('rw' => 'unknown'));
            $this->fail();
        } catch(Doctrine_Transaction_Exception $e) {
            $this->pass();
        }
    }
    public function testSetIsolationExecutesSql() {
        $this->transaction->setIsolation('READ UNCOMMITTED');
        $this->transaction->setIsolation('READ COMMITTED');
        $this->transaction->setIsolation('REPEATABLE READ');
zYne's avatar
zYne committed
49
        $this->transaction->setIsolation('SERIALIZABLE');                      
50

zYne's avatar
zYne committed
51 52 53 54
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT TABLE STABILITY');
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT');
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO RECORD_VERSION');
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED RECORD_VERSION');
55 56 57 58
    }
    public function testSetIsolationSupportsReadWriteOptions() {
        $this->transaction->setIsolation('SERIALIZABLE', array('rw' => 'READ ONLY'));

zYne's avatar
zYne committed
59
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION READ ONLY ISOLATION LEVEL SNAPSHOT TABLE STABILITY');
60 61 62

        $this->transaction->setIsolation('SERIALIZABLE', array('rw' => 'READ WRITE'));

zYne's avatar
zYne committed
63
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION READ WRITE ISOLATION LEVEL SNAPSHOT TABLE STABILITY');
64 65 66 67
    }
    public function testSetIsolationSupportsWaitOptions() {
        $this->transaction->setIsolation('SERIALIZABLE', array('wait' => 'NO WAIT'));

zYne's avatar
zYne committed
68
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION NO WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY');
69 70 71

        $this->transaction->setIsolation('SERIALIZABLE', array('wait' => 'WAIT'));

zYne's avatar
zYne committed
72
        $this->assertEqual($this->adapter->pop(), 'SET TRANSACTION WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY');
73 74
    }
}