2006-11-23 02:35:34 +03:00
|
|
|
<?php
|
|
|
|
class Doctrine_Transaction_TestCase extends Doctrine_Driver_UnitTestCase {
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct('sqlite', true);
|
|
|
|
}
|
2006-12-01 02:51:44 +03:00
|
|
|
/**
|
2006-11-23 02:35:34 +03:00
|
|
|
public function testCreateSavepointIsOnlyImplementedAtDriverLevel() {
|
|
|
|
try {
|
2006-12-01 02:51:44 +03:00
|
|
|
$this->transaction->beginTransaction('point');
|
2006-11-23 02:35:34 +03:00
|
|
|
$this->fail();
|
|
|
|
} catch(Doctrine_Transaction_Exception $e) {
|
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testReleaseSavepointIsOnlyImplementedAtDriverLevel() {
|
|
|
|
try {
|
2006-12-01 02:51:44 +03:00
|
|
|
$this->transaction->commit('point');
|
2006-11-23 02:35:34 +03:00
|
|
|
$this->fail();
|
|
|
|
} catch(Doctrine_Transaction_Exception $e) {
|
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
2006-12-01 02:51:44 +03:00
|
|
|
*/
|
2006-11-23 02:35:34 +03:00
|
|
|
public function testRollbackSavepointIsOnlyImplementedAtDriverLevel() {
|
|
|
|
try {
|
2006-12-01 02:51:44 +03:00
|
|
|
$this->transaction->beginTransaction();
|
|
|
|
|
|
|
|
$this->transaction->rollback('point');
|
2006-11-23 02:35:34 +03:00
|
|
|
$this->fail();
|
|
|
|
} catch(Doctrine_Transaction_Exception $e) {
|
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testSetIsolationIsOnlyImplementedAtDriverLevel() {
|
|
|
|
try {
|
|
|
|
$this->transaction->setIsolation('READ UNCOMMITTED');
|
|
|
|
$this->fail();
|
|
|
|
} catch(Doctrine_Transaction_Exception $e) {
|
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testGetIsolationIsOnlyImplementedAtDriverLevel() {
|
|
|
|
try {
|
|
|
|
$this->transaction->GetIsolation('READ UNCOMMITTED');
|
|
|
|
$this->fail();
|
|
|
|
} catch(Doctrine_Transaction_Exception $e) {
|
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testTransactionLevelIsInitiallyZero() {
|
|
|
|
$this->assertEqual($this->transaction->getTransactionLevel(), 0);
|
|
|
|
}
|
|
|
|
public function testGetStateReturnsStateConstant() {
|
|
|
|
$this->assertEqual($this->transaction->getState(), Doctrine_Transaction::STATE_SLEEP);
|
|
|
|
}
|
2006-12-01 02:51:44 +03:00
|
|
|
public function testCommittingNotActiveTransactionReturnsFalse() {
|
|
|
|
$this->assertEqual($this->transaction->commit(), false);
|
2006-11-23 02:35:34 +03:00
|
|
|
}
|
|
|
|
public function testExceptionIsThrownWhenUsingRollbackOnNotActiveTransaction() {
|
2006-12-01 02:51:44 +03:00
|
|
|
$this->assertEqual($this->transaction->rollback(), false);
|
2006-11-23 02:35:34 +03:00
|
|
|
}
|
|
|
|
public function testBeginTransactionStartsNewTransaction() {
|
|
|
|
$this->transaction->beginTransaction();
|
|
|
|
|
|
|
|
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
|
|
|
|
}
|
|
|
|
public function testCommitMethodCommitsCurrentTransaction() {
|
|
|
|
$this->transaction->commit();
|
|
|
|
|
|
|
|
$this->assertEqual($this->adapter->pop(), 'COMMIT');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|