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.
- Selenium RC server
- 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.