Testing PHP Projects using Yii Framework in Netbeans

This post aims to give information how to test PHP Projects using Yii Framework using Netbeans IDE. Please take note that this tutorial is for users using Ubuntu Linux Distributions.

Install Requirements

  • PHPUnit
  • Selenium RC server

Installing PHPUnit

  • Open Terminal
  • Install PHPUnit by running the following commands:

sudo pear config-set auto_discover 1
sudo pear install pear.phpunit.de/PHPUnit

  • Install other PHPUnit’s required packages:

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
sudo pear install phpunit/PHPUnit_Selenium
sudo pear install phpunit/PHPUnit_SkeletonGenerator
pear install phpunit/DbUnit

Installing Selenium RC

  • Download the Selenium RC server here.
  • Extract the zip file
  • Copy the file to your home folder by running the following command in Terminal:

sudo mv /path/to/extracted/location/of/selenium-remote-control-1.0.3 /path/to/home/folder

Setup Netbeans and Yii Project Settings

  • Open “Tools > Options > PHP > Unit Testing” and set the correct path to the launch script. Usually /usr/bin/phpunit in Linux.
  • Install SeleniumRC by getting the NetBeans plugin
    • Open “Tools > Plugins > Available Plugins”
    • Install “Selenium Module for PHP”
  • Configure project options
    • Open “File > Project properties > Sources” and set “Test Folder” to [PROJECT ROOT]/protected/tests (If the whole project testing doesn’t work, try [PROJECT ROOT]/protected/tests/unit)
    • Open “File > Project properties > PHPUnit” and set “Use Bootstrap” to [PROJECT ROOT]/protected/tests/bootstrap.php, and “Use XML Configuration” to [PROJECT ROOT]/protected/tests/phpunit.xml


  • Test whole project: Alt+F6
  • Test single file: Shift-F6
  • Check code coverage (right click project > Code Coverage)

NOTE: Before running the test cases for functional testing, you should run the selenium server by running the following in Terminal

java -jar /path/to/home/folder/selenium-remote-control-1.0.3/selenium-server-1.0.3/selenium-server.jar

Conclusion: If you get something the image below after, it means you successfully installed and configured the automated testing of your Yii project.  


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

I did not put any annoying ads which are forcing you to open other sites and install apps.

However, maintaining this site isn't a freebie. I put this up to help fellow travelers in planning their trip and expecting no return.

This time, I am asking for a small favor by subscribing to the youtube channel below which focuses on travel videos and IT-related tips.

It only takes one click and tadan... it's done! 

Also, please like this blog's Facebook page to show your support and get updates on the latest articles.