I’m following the book and am now up to Chapter 3 (page 50).
When running the test with PHPUnit I get the following output:
PHPUnit 3.4.15 by Sebastian Bergmann.
Fatal error: Class 'Controller' not found in C:\xampplite\htdocs\yii\testdrive\p
rotected\controllers\MessageController.php on line 4
The contents of my MessageTest.php are as follows:
class MessageTest extends CTestCase
public function testRepeat()
$message = new MessageController('messageTest');
$yell = "helloooo";
The error is triggered when invoking “new MessageController(‘messageTest’)” in the code above.
Part of MessageController.php looks like this:
class MessageController extends Controller
public function actionRepeat($var)
Are you sure you are using Yii version 1.1.2? Your revision # indicates a later version. The base controller class "Controller" was introduced in the auto-generated code as of verion 1.1.2 (SVN r2086), but there may be slight differences in the auto-generated code in the version you are using
I know the title of the book just states Yii 1.1, but on page 18 as part of the installation, the book indicates it is using specifically Yii 1.1.2 for all examples. ALL of the ideas and concepts covered will translate to other 1.1.x versions, but if using a version other than 1.1.2, there may be subtle differences in the examples provided.
Please ensure you are using Yii version 1.1.2 for the best experience when following along with the specific examples provided in the book.
I can get it working though by adding “require(’../models/Project.php’);”
An unusual thing: when I run the test and receive the error, and empty file named ‘Project.php’ is created in protected/tests/
This file is created when code is at: Yiibase.php, line 354. Appearantly it cannot find the project model in any of the first two ifs.
public static function autoload($className)
// use include so that the error PHP file may appear
include($className.'.php'); // right after this is executed, the file is created
I am now using exactly the same Yii and TrackStar code at home as at my work environment, could the difference be somewhere else?