CH13: SysMessageTest Failure.

I am on CH13 of the book specifically page: 326.

My SysMessageTest is failing:

My Code is as follows:



class SysMessageTest extends CDbTestCase


        public $fixtures=array(




        public function testGetLatest()


            $message = SysMessage::getLatest();

            $this->assertTrue($message instanceof SysMessage);





return array(


        'message' => 'This is a test message',

        'create_time' => new CDbExpression('NOW()'),

        'create_user_id' => 1,

        'update_time' => new CDbExpression('NOW()'),

        'update_user_id' => 1,



GetLatest function in SysMessage AR Class

public static function getLatest()


                //see if it is in the cache, if so, just return it

                if( ($cache=Yii::app()->cache)!==null)




                        return $sysMessage;



                //The system message was either not found in the cache, or

                //there is no cache component defined for the application

                //retrieve the system message from the database

                $sysMessage = SysMessage::model()->find(array(

                    'order'=>'t.update_time DESC',



                if($sysMessage != null)


                    //a valid message was found. Store it in cache for future retrievals



                    return $sysMessage;



                    return null;


Now I did get this test to pass by continuing on and generating the cache with the ProjectController::actionIndex call. However once I changed the cache location in the test.php configuration so the dev and test cache locations are different it would then again fail.