title: How to begin and rollback a database transaction to wrap a PHPUnit suite for Magento
body: <p>I'd like to use a transaction rollback method to isolate my database for unit testing purposes.  Ideally, I would use a structure something like this: </p>
  
  <pre><code>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();
  }
  </code></pre>
  
  <p>Unfortunately the <code>Mage_Core_Model_Resource_Transaction</code> class doesn't expose public begin/rollbackTransaction functions.  I can't find any public Magento functions to meet the requirement.  Is there a Zend equivalent that will work?</p>
  
  <p>I guess I could rewrite <code>Mage_Core_Model_Resource_Transaction</code> and add public wrappers for the protected methods, but I'm hesitant to override such a core class. </p>
  
  <p>I have also tried using </p>
  
  <pre><code>$this-&gt;model = Mage::getModel('model_being_tested');
  $this-&gt;model-&gt;getResource()-&gt;beginTransaction(); 
  ...
  $this-&gt;model-&gt;getResource()-&gt;rollBack();
  </code></pre>
  
  <p>and then use the <code>$this-&gt;model</code> in the tests but that can't be used in static functions. </p>
  
  <p>Any suggestions or alternative architectures?  Thanks in advance.</p>