Problems with Yii and PHPunit

I first started this problem when I thought it was only an issue in the Yii book (http://www.yiiframework.com/forum/index.php?/topic/11723-chapter-3-messagetest/). It turns out it seems specific to my installation environment, so I thought I’d better repost it under the circumstances.

Yii: r2468 (1.1.5-dev)

XAMPP: 1.7.3

PHP: 5.3.1

PHPUnit: 3.4.15

SeleniumRC: 1.0.1

WebRoot: C:\www

Yii: C:\www\yii

When I run the blog demo (but any yii project I have will fail in a similar way) I receive the following output:




C:\www\yii\demos\blog\protected\tests>phpunit --verbose unit

PHPUnit 3.4.15 by Sebastian Bergmann.


unit

 CommentTest


Fatal error: Class 'Post' not found in C:\www\yii\framework\db\ar\CActiveRecord.

php on line 352



It also creates and empty file "Post.php" in "C:\www\yii\demos\blog\protected\tests".

The only workaround I was able to use is manually adding the required files into WebTestCase.php. In case of unit/CommentTest.php, I have to add:


require_once('../models/Post.php');

require_once('../models/Comment.php');

At home with the same XAMPP and PHP versions, and exactly the same Yii code it is working fine.

Anyone has an idea?

The same thing happens now when I’m developing my first shell application. I run…


C:\www\trackstar>..\yii\framework\yiic shell


Fatal error: Class 'Controller' not found in C:\www\trackstar\protected\controll

ers\SiteController.php on line 4

…and the empty “Controller.php” file is created in “C:\www\trackstar”. When I manually include the file (require_once(‘protected/components/Controller.php’)) it runs. Weird stuff…

I fixed my problem by installing PHP on a standalone basis, and updating my PATH env var.

The problem was somehow caused by either the PHP installation or the environment.