of course
Thiis the data file at trackstar/protected/tests/fixtures/tbl_project.php
<?php
return array(
'project1' => array(
'name' => 'Test Project 1',
'description' => 'This is test project 1',
'create_time' => '',
'create_user_id' => '',
'update_time' => '',
'update_user_id' => '',
),
'project2' => array(
'name' => 'Test Project 2',
'description' => 'This is test project 2',
'create_time' => '',
'create_user_id' => '',
'update_time' => '',
'update_user_id' => '',
),
'project3' => array(
'name' => 'Test Project 3',
'description' => 'This is test project 3',
'create_time' => '',
'create_user_id' => '',
'update_time' => '',
'update_user_id' => '',
),
);
?>
But this is the file you are looking for.
this file is at trackstar/protected/tests/unit/ProjectTest.php
<?php
class ProjectTest extends CTestCase
{
//specify the fixture file
public $fixtures = array('projects'=>'Project');
public function testRead()
{
$retrievedProject = $this->projects('project1');
$this->assertTrue($retrievedProject instanceof Project);
$this->assertEquals('Test Project 1',$retrievedProject->name);
}
/*public function testCreate()
{
//create a new project
$newProject = new Project();
$newProjectName = "Test Project Creation";
$newProject->setAttributes(
array(
'name' => $newProjectName
,
'description' => "Creation of Test Project"
,
'create_time' => "2009-09-09 09:09:09"
,
'create_user_id'=> 1
,
'update_time' => "2009-09-09 09:09:09"
,
'update_user_id'=> 1
,
)
);
//$newProject->id = 1;
$this->assertTrue($newProject->save(false));
//READ back the newly created project
$retrievedProject=Project::model()->findByPk($newProject->id);
$this->assertTrue($retrievedProject instanceof Project);
$this->assertEquals($newProjectName,$retrievedProject->name);
}*/
/*public function testUpdate()
{
//update the newly created project
$project = $this->projects('project2');
$updatedProjectName = "Updated Test Project 2";
$newProject->name = $updatedProjectName;
$this->assertTrue($newProject->save(false));
//read back the record again to ensure the update worked
$updatedProject = Project::model()->findByPk($project->id);
$this->assertTrue($updatedProject instanceof Project);
$this->assertEquals($updatedProjectName,$updatedProject->name);
}*/
/*public function testDelete()
{
$project = $this->projects('project2');
$savedProjectId = $project->id;
$this->assertTrue($project->delete());
$deletedProject = Project::model()->findByPk($savedProjectId);
$this->assertEquals(NULL,$deletedProject);
}*/
/*
public function testCRUD()
{
//print_r(Yii::app()->db);
//echo "\n";
//$this->assertNotEquals(NULL,Yii::app()->db);
//create a new project
$newProject = new Project();
$newProjectName = "Test Project 1";
$newProject->setAttributes(
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
,
)
);
$newProject->id = 1;
//$this->assertTrue($newProject->save(false));
//echo "id is".$newProject->id."\n";
//READ back the newly created project
$retrievedProject=Project::model()->findByPk($newProject->id);
//$this->assertTrue($retrievedProject instanceof Project);
//$this->assertEquals($newProjectName,$retrievedProject->name);
//update the newly created project
$updatedProjectName = "Reupdated Test Project 1";
$newProject->name = $updatedProjectName;
//$this->assertTrue($newProject->save(false));
// Delete the project
$newProjectId = $newProject->id;
$this->assertTrue($newProject->delete());
$deletedProject = Project::model()->findByPK($newProjectId);
$this->assertEquals(NULL,$deletedProject);
}
*/
}