Please read DigitalZombie’s reply for what looks to be the answer. You must ensure that the Project class extends the base active record class TrackStarActiveRecord. It is in this base class where the create_user_id is being set to the current app user id, and indeed part of what is being tested:
* This is the model class for table "tbl_project".
class Project extends [b]TrackStarActiveRecord[/b]
abstract class TrackStarActiveRecord extends CActiveRecord
* Prepares create_time, create_user_id, update_time and update_user_id attributes before performing validation.
protected function beforeValidate()
// set the create date, last updated date and the user doing the creating
//not a new record, so just set the last updated time and last updated user id
Thanks for posting this. I also missed it. That one small word ‘false’ is easy to miss. Most of the issues I’ve had through chapter 8 so far have been tiny mistakes such as this so we have to go back and carefully scan every line altered. Not so fun if you take big steps and have to go way back.
I have checked my code perfect as per given book and dually checked as per "khad" comments on this forum i dont have this silly mistakes. My code is :
public function testCreate()
//CREATE a new Project
$newProjectName = 'Test Project Creation';
'name' => $newProjectName,
'description' => 'This is a test for new project creation',
//set the application user id to the first user in our users fixture data
//save the new project, triggering attribute validation
//READ back the newly created Project to ensure the creation worked
$this->assertTrue($retrievedProject instanceof Project);
i got the same problem, but i fix this by make sure all the variables name, cause the code was not same at all, for example: in the testUpdate there is, $updatedProject = Project::model()->findByPk($project->id);
but in the previous code that’s written, $updatedProject = Project::model()->findByPk($newProject->id);