How to do a proper integration test with PHP

By | October 18, 2013

One of the phases of developing is testing if all your code is working, or if you are a Test / Behavior Driven Developer then it will start with this. Most of this testing can be done using PHPUnit, validating the basics of your classes and making sure they return the data you are expecting. But what about UI testing and verifying that all of your JavaScript is working after a rework. Usually you would do something like a Selenium test to verify this.

Well one of the problems I faced doing this for PHP was that I had to run a server with the PHP web-application on it, but that means setting up a dedicated server just for the integration testing. Which is anything but a desired solution. So I started looking for a way to have this run locally, using a small server you can start-up and kill during the test run.

To solve this, at least in part, I started setting up a Maven project in Java, that could proxy any incoming request to the PHP-cgi interface and relay the result back to the browser. Now it is nowhere near finished, but you can take a look at the initial work on the github project page.

Leave a Reply