Wednesday, May 16, 2012

YII Unit test troubleshooting FATA ERROR : Class not found Error

Recently i started using YII Framework, its so amazing. While using unit tests i found some issues and wasted a lot of time for tuning it. Here is my observations which worked at the end on WINDOWS machine -


ASSUMPTIONS -
a) you have pear installed
b) PHP xdebug installed [pls follow my other post http://usemytips.blogspot.it/2012/05/php-xdebug-installation-simplest-method.html ]




Lets start the magic -


STEP 1 --------------------------------


UPDATE PEAR - using your command prompt update PEAR 


 cmd> pear channel-update pear.php.net


 cmd> pear list-upgrade




now for all upgrades listed above follow the upgrades by using command 


cmd> pear install -f pear.php.net/XXXX    [where XXXX is upgrade name listed from above command for example if pear upgrade is needed the command will become 


cmd> pear install -f pear.php.net/PEAR




STEP 2 --------------------------------


UPDATE/INSTALL PHPUNIT - using your command prompt update/install phpunit 


[UPGRADE]
 cmd> pear channel-update pear.phpunit.de


 cmd> pear list-upgrade


[INSTALL]
cmd> pear install -f  pear.phpunit.de /PHPUnit    




OK, now you have installed phpunit, updated Pear libs, and hopefully x-debug working well. All are PHP version dependent so make sure that they are compatible.


STEP 3 ------check your PHP.ini for include_path, it must have the pear/phpunit pointers in it. like 


include_path="C:\php;c:\php\pear;C:\php\pear\phpunit"






 STEP 3 ---------------------YII integration-----------


make sure that your /protected/tests/bootstrap.php has all file pointers set to locate yiii.php. from your command prompt locate the tests folder -


cmd > cd C:\YOUR YII ROOT\YOUR WEB APP\protected\tests  [ENTER]


C:\YOUR YII ROOT\YOUR WEB APP\protected\tests> php unit/DbTest.php   [ENTER]




 remember php bold and large is for php command [location of php.exe]. If someone have different directory structure installation it can be 


C:\YOUR YII ROOT\YOUR WEB APP\protected\tests> YOURDRIVE\PHP EXEPATH  unit\DbTest.php  




[NOTE - If you get error that php is not a suffix for php.exe just run a command in php


CMD>pear   config-set    php_suffix   .exe

No comments:

Post a Comment