title: Magento/PHPUnit - force an exception
body: <p>I'm using phpunit and the ecomdev module to unit test Magento. For a particular class the last code that needs to be tested is an exception on attempting to save a model in a try/catch. The only way I can see to get to the exception is alter the database temporarily. So I changed the table name which works, but then I have to name it back. If the test itself fails I'm in an inconsistent state. </p>
  
  <p>I'd really like to get that code tested so the coverage is 100%. Otherwise I'll be wondering why it's  98% until I look at the code and remember the exception isn't tested.</p>
  
  <p>I was trying to close the connection but I need it to log the exception. So I'm wondering if maybe there is something I can temporarily do to the model or resource model to cause the save to raise an exception. Something that would be reset on the next load.</p>
  
  <p>One note - I can't see anyway that manipulating data will cause the exception. Again the only scenario I see causing an exception in production is if the database connection goes away.</p>
  
  <p>Any ideas?</p>
  
  <p>Edit:
  Sample Code:</p>
  
  <pre><code>public function logStuff($stuff){
  
      try{
          Mage::getModel('my/stuff')
              -&gt;setData('stuff', $stuff)
              -&gt;save();
  
      }catch(Exception $e){
          Mage::helper('log/error')-&gt;logError(__METHOD__, "Could not save stuff: ". $e-&gt;getMessage());
      }
  }
  </code></pre>