mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Moved readonly section of TransactionTest into postgresql/ module
This commit is contained in:
parent
b70ff87658
commit
dd6f9ed005
@ -45,46 +45,9 @@ class TransactionTest extends SapphireTest {
|
|||||||
//These pages should NOT exist, we reverted to a savepoint:
|
//These pages should NOT exist, we reverted to a savepoint:
|
||||||
$this->assertFalse(is_object($third) && $third->exists());
|
$this->assertFalse(is_object($third) && $third->exists());
|
||||||
$this->assertFalse(is_object($forth) && $forth->exists());
|
$this->assertFalse(is_object($forth) && $forth->exists());
|
||||||
|
} else {
|
||||||
|
$this->markTestSkipped('Current database does not support transactions');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testReadOnlyTransaction(){
|
|
||||||
|
|
||||||
if(DB::getConn()->supportsTransactions()==true){
|
|
||||||
|
|
||||||
$page=new Page();
|
|
||||||
$page->Title='Read only success';
|
|
||||||
$page->write();
|
|
||||||
|
|
||||||
DB::getConn()->transactionStart('READ ONLY');
|
|
||||||
|
|
||||||
try {
|
|
||||||
$page=new Page();
|
|
||||||
$page->Title='Read only page failed';
|
|
||||||
$page->write();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
//could not write this record
|
|
||||||
//We need to do a rollback or a commit otherwise we'll get error messages
|
|
||||||
DB::getConn()->transactionRollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::getConn()->transactionEnd();
|
|
||||||
|
|
||||||
DataObject::flush_and_destroy_cache();
|
|
||||||
|
|
||||||
$success=DataObject::get('Page', "\"Title\"='Read only success'");
|
|
||||||
$fail=DataObject::get('Page', "\"Title\"='Read only page failed'");
|
|
||||||
|
|
||||||
//This page should be in the system
|
|
||||||
$this->assertTrue(is_object($success) && $success->exists());
|
|
||||||
|
|
||||||
//This page should NOT exist, we had 'read only' permissions
|
|
||||||
$this->assertFalse(is_object($fail) && $fail->exists());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
Loading…
x
Reference in New Issue
Block a user