MSRQ
(Sanroman Me)
March 31, 2011, 8:35am
1
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() {
$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
Haensel
(Johannes)
March 31, 2011, 8:43am
2
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
MSRQ
(Sanroman Me)
March 31, 2011, 8:45am
3
Yes, Project.php is created and basic CRUD is working
Also tested
<?php
class ProjectTest extends CDbTestCase {
public function testCRUD() {
//Create a new project
$newProject=new Project;
}
}
?>
with no results
Thanks
Haensel
(Johannes)
March 31, 2011, 9:03am
4
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
MSRQ
(Sanroman Me)
March 31, 2011, 5:13pm
5
Haensel:
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?
Haensel
(Johannes)
March 31, 2011, 6:46pm
6
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.