Setting up Yii Testing with XAMPP, PHPUnit and Selenium

Setup Yii Testing

In protected/tests/WebTestCase.php, change TEST_BASE_URL to your project


Check protected/tests/bootstrap.php to make sure it is configured in a reasonable manner.  I believe in most cases it will be fine – I am using the yii-environment extension, and needed to copy over my config so it would read from existing config files.  Take note of what $config is set to.  Default is as follows:


In protected/config/test.php (or whatever config file you’ve setup for testing above), make sure CDbFixtureManager component is registered.

'components' => array(

In webapp/index-test.php

Should be configured similarly to index.php, with $config pointing to your config from above


Install PHP Unit

  1. pear config-set auto_discover 1
  2. pear channel-update
  3. pear upgrade-all
  4. pear channel-discover
  5. pear channel-discover
  6. pear channel-discover
  7. pear update-channels
  8. pear install -a -f phpunit/PHPUnit
  9. pear install –alldeps
  10. pear install –alldeps
  11. pear install phpunit/PHPUnit_Selenium

Install and Run Selenium Server

  1. Download Selenium Server (selenium-server-standalone-x.xx.x.jar) from
  2. Unzip to an easy to find location (I just put it in c:\apps\selenium)
  3. Switch to the Selenium directory and start Selenium Server
> java -jar selenium-server.jar

Run Tests (test testing?)

The default webapp skeleton has some functional tests already configured (SiteTest.php) – this is a good way to make sure your testing environment has been setup correctly.

Run all functional tests:

> cd c:\apps\xampp\htdocs\webapp\protected\tests
> phpunit --verbose functional

You should get a summary on the command line informing you of the results…

Tests: 3, Assertions: 3, Errors: 0.

Leave a Reply

Your email address will not be published. Required fields are marked *