Problem with (very) basic model testing

Hello

Just starting with Yii framework. I tried to try some model testing, by the book.

Here is my test class:

//DbTest.php

<?php

class DbTest extends CDbTestCase {

public function testCRUD() {

&#036;newProject=new Project;

}

}

?>

And executing

C:\xampp\htdocs\trackstar\protected\tests>phpunit unit/DbTest.php

PHPUnit 3.5.13 by Sebastian Bergmann.

Fatal error: Class ‘Project’ not found in C:\xampp\htdocs\trackstar\protected\te

sts\unit\DbTest.php on line 8

Any ideas?

Thanks in advance

Hi,

Please post topics like that in http://www.yiiframework.com/forum/index.php?/forum/38-yii-book-discussions/

Are you sure that you have a file called "Project.php" in your models folder of your application? If not than this is the problem and you should create one

Yes, Project.php is created and basic CRUD is working

Also tested

<?php

class ProjectTest extends CDbTestCase {

public function testCRUD() {

//Create a new project


&#036;newProject=new Project;

}

}

?>

with no results

Thanks

Try this at the top of your testfile, although I think the Project model should have been autoloaded already.


Yii::import('application.models.Project');

If you still experience any problems than there is something wrong with your model class I think

That worked. Why the autoload property didn’t work?

Check the main.php in your config folder for the following lines:


'import'=>array('application.models.*',........

If that is the case than I don’t know why it wasn’t loaded correctly.