PHPUnit Agile Web Developement with Yii

I'm After reading other similar posts I felt I've followed everything to the letter, hence my confusion and this post:

I'm running: - Windows 7 64bit - Wamp Server 2.0 with php 5.2.5

I'm reading the packt Agile Web Development with Yii and PHP5

Actions so far:

  1. Installed PEAR in c:\wamp\bin\php5.2.5\PEAR\pear (it created a subfolder inside 'PEAR')
  2. Installed and Setup Selenium RC
  3. Added the PEAR_ENV.reg file for Environment Variables
  4. Restarted and Confirmed PEAR is working by typing 'pear' in command prompt (works in any subfolder as well)
  5. Installed PHPUnit via PEAR and confirmed 'phpunit' is working via command prompt. Tested phpunit with selenium for the Yii testcase at 'functional/SiteTest.php'
  6. changed and tested the include_path in both php.ini files (in the php5.2.5 folder and the apache folder) to 'c:\wamp\bin\php5.2.5\PEAR\pear'. Turns out both need to be the same for phpunit and pear to work (?)

The problem: the following command works when I type via command prompt:

cd c:\wamp\www\yiidemo\protected\tests
phpunit functional\SiteTest.php

phpunit works with selenium for testing the site with firefox.

But when I create an empty class for testing as stated in the book and run this:

phpunit unit\MessageTest.php

I get this:

"Warning: require(PHPUnit/Autoload.php): failed to open stream: No such file or directory in c:\wamp\www\yiidemo\protected\tests\unit\MessageTest.php"

But if I enter the unit folder and try the command:

phpunit MessageTest.php

I get an error message stating

"Fatal Error: Class 'CTestCase' not found in "c:\wamp\www\yiidemo\protected\tests\unit\MessageTest.php" on line 3

class MessageTest extends CTestCase


Any idea what I'm doing wrong. I've come a long way to this point and quite stuck since the command lines are working.


Update. Problem solved.

Detailed reasons why the problem persisted:

  • There was no Autoload.php file in the phpunit version I used, so copying the latest build from github and dumping it in the pear folder and tinkering from there didn't work with setup/install (missing references).

  • Even if I copied only the Autoload.php file from the github folder (to see what would happen), further missing references convinced me what Yii expected was far different from what I had installed.

  • PEAR unfortunately dictates WHICH VERSION of phpunit to install BASED ON YOUR PHP Version. Since I was using php5.2.5, the highest version of phpunit it would install was a version without Autoload.php, even if you used the --force --alldeps options

Moving Forward.

  • Upgrade your setup at least PHP5.3.4

  • run go-pear.phar in \path\to\php\php5.3.4 and accept default parameters

  • Add PEAR_ENV.reg to registry

  • install phpunit

  • install phpunit/selenium

NOTE to Wampserver users (IMPORTANT!!) Upgrade to ONLYwampserver 2.1, NOT 2.2! 2.2 doesn't seem to have its curl extension working, which poses a problem when installing phpunit selenium. Even with Wamp 2.1 (I was upgrading from 2.0), you have to manually enable curl extension in both php.ini files in the php and apache folders (As far as I tested PEAR uses PHP's php.ini while phpunit used the apache's php.ini).

Using WAMP 2.2 gave me "side by side" configuration error even on enabling curl via php.ini. See Link: Wamp Server 2.2 Windows 7 64-bit and curl not working side-by-side configuration incorrect

the curl extension is needed for installing Selenium for PHPUnit

Take all this into account and you shouldn't have a problem!

Need Your Help

MediaPlayer prepare() method crashing after FileOutputStream (Android)

android file audio udp media-player

I am writing an Android test program to record my voice, send it over UDP, and then play it. Right now, to make things simple, I run two threads, one records and send the data, the other receives i...

How can I run elisp code automatically in emacs?

emacs elisp

I have a debugging/monitoring system for a particular application. I would like to allow monitoring/debugging from an emacs session, and have it run automatically.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.