CDbTestCase

I don’t know how to use the CDbTestCase class.

Can someone help me, please?

This is an example of unit test from Comment class, but … i don’t understand

class CommentTest extends CDbTestCase

{

public $fixtures=array( 


    'posts'=>'Post',  //WHAT MEANS THIS?


    'comments'=>'Comment',// AND THIS?


);





......

}

::::::::::::::::.

this is the test method of the Comment class

i understand this, but i don’t understand the above

public function testApprove()

{

// insert a comment in pending status


$comment=new Comment;


$comment->setAttributes(array(


    'content'=>'comment 1',


    'status'=>Comment::STATUS_PENDING,


    'createTime'=>time(),


    'author'=>'me',


    'email'=>'me@example.com',


    'postId'=>$this->posts['sample1']['id'],


),false);


$this->assertTrue($comment->save(false));





// verify the comment is in pending status


$comment=Comment::model()->findByPk($comment->id);


$this->assertTrue($comment instanceof Comment);


$this->assertEquals(Comment::STATUS_PENDING,$comment->status);





// call approve() and verify the comment is in approved status


$comment->approve();


$this->assertEquals(Comment::STATUS_APPROVED,$comment->status);


$comment=Comment::model()->findByPk($comment->id);


$this->assertEquals(Comment::STATUS_APPROVED,$comment->status);

}

I NEED HELP, PLEASE, I AM A BEGINNER

The array key in $fixtures represent the database table and fixture file name (excluding .php), the array value is the Active Record class name that represents the table.

Calling $this->posts will return the fixtures array while $this->Post(0) will return a new Post object with the fixtures array of 0 (zero) index.