<?php
class ProjectTest extends CDbTestCase
{
public function testCRUD()
{
$newProject = new Project;
$newProjectName = 'Test Project 1';
$newProject->setAttribute(
array('name'=>$newProjectName,
'description'=>'Test Project Number One',
'create_time'=>'2010-01-01 00:00:00',
'create_user_id'=> 1,
'update_time'=>'2010-01-01 00:00:00',
'update_user_id'=> 1,)
);
$this->assertTrue($newProject->save(false));
}
}
?>
I have a ar class named Project…in table these are the list of items i have …I m trying to test whether this code inserts the data in to that table or not, using phpunit test in command line but it gives error (Missing argument 2 for CActiveRecord::setAttribute() ) any help
You are using the wrong function (setAttribute) instead of setAttribute*s*. You should use setAttribute*s* if you want to fill the values of a Model object with an array.
Details here
setAttribute is used to set a specific value of a model and it takes two parameters, the attribute name and its value