How is this fixture being referenced?

I’m following along in the Yii book and am on CH5 (page 101). In our unit tests, it has us define an array that specifies which fixture(s) to use:


class ProjectTest extends CDbTestCase {

}

public $fixtures=array (

'projects'=>'Project', );

But, the fixtures file is created in ‘protected/tests/fixtures/tbl_project.php’ and clearly isn’t named ‘projects’. How does Yii infer this? Note: my DB table is named tbl_project.

Thanks :)

Actually, fixtures are uses for let your yii application to use test database, and test database will populated with certain state. In your example, Project model are going to use by your testCase. Before running every test, it will check protected/tests/fixtures/ for underlying database as array. Then clear and reset database table with fixtures data.

protected/tests/fixtures/tbl_project.php is find, because you specify tableName property of ‘Project’ ActiveRecord Model with ‘tbl_project’ or ‘{{project}}’ value.