Functional testing with Selenium and PHPUnit

Installing this stuff is simple in principle but a bit of a pig in practice

1. Install pear
sudo php /tmp/go-pear.phar

2. Install PHPUnit
pear config-set auto_discover 1
sudo pear channel-discover
pear install --alldeps
sudo pear install phpunit/DbUnit
sudo pear install phpunit/PHPUnit_Story

3. Install PHPUnit selenium package
pear install phpunit/PHPUnit_Selenium

4. Install Selenium Server
Download a distribution archive of Selenium Server.
Unzip the distribution archive and copy selenium-server-standalone-2.9.0.jar (check the version suffix) to /usr/local/bin, for instance.
Start the Selenium Server server by running java -jar /usr/local/bin/selenium-server-standalone-2.9.0.jar

Then execute test file using
phpunit --colors testSubmitLoginForm test.php

PHPUnit 3.7.9 by Sebastian Bergmann.


Time: 30 seconds, Memory: 5.25Mb

OK (2 tests, 3 assertions)

All sounds simple but in reality several hours of dicking around with Pear channels may ensue before final success…

Useful links: