title: How do I mock an ActiveRecord object in Yii?
body: <p>In Yii I want to perform some unit tests on a class that uses ActiveRecord objects. For example, I have a Translation ActiveRecord. When I try to create a mock object for it I get an error. </p>
  
  <p>In my test I have the line:</p>
  
  <pre><code>$translation = $this-&gt;getMock("Translation");
  </code></pre>
  
  <p>And then I get this error when I run my test:</p>
  
  <pre><code>PHPUnit 3.7.30 by Sebastian Bergmann.
  
  Configuration read from /Users/riverstyx/Sites/protected/tests/phpunit.xml
  
  E.
  
  Time: 1.27 seconds, Memory: 6.25Mb
  
  There was 1 error:
  
  1) TranslationManagerTest::testCreateNewTranslation
  Trying to get property of non-object
  
  /Users/riverstyx/yii/framework/db/ar/CActiveRecord.php:79
  /Users/riverstyx/Sites/protected/tests/unit/TranslationManagerTest.php:8
  
  FAILURES!
  Tests: 2, Assertions: 0, Errors: 1
  </code></pre>
  
  <p>I understand the concept of using fixtures in Yii however I don't want to have to rely on a database to do my testing. We use MySQL in production, so creating a temporary in-memory SQLITE database seems weird because it doesn't match our actual MySQL environment and also there are some syntax nuances (ie. UTC_TIMESTAMP() doesnt exist in SQLITE). </p>
  
  <p>Ideally (as with all unit tests I guess), I want to test my TranslationManager class in isolation from the active record. </p>
  
  <p>Any help would be appreciated :)</p>