I would like to use the transaction rollback method to isolate my database for unit testing purposes. Ideally, I would use a structure like this:
public static function setUpBeforeClass(){
Mage_Core_Model_Resource_Transaction::beginTransaction();
}
public function testOne(){...}
public function testTwo(){...}
public static function tearDownAfterClass(){
Mage_Core_Model_Resource_Transaction::rollBack();
}
Unfortunately, the class Mage_Core_Model_Resource_Transactiondoes not provide the public begin / rollbackTransaction function. I cannot find any public Magento functions to fulfill this requirement. Is there a Zend equivalent that will work?
I think I could rewrite Mage_Core_Model_Resource_Transactionand add public shells for protected methods, but I hesitate to redefine such a main class.
I also tried using
$this->model = Mage::getModel('model_being_tested');
$this->model->getResource()->beginTransaction();
...
$this->model->getResource()->rollBack();
and then use $this->modelin tests, but cannot be used in static functions.
? .