Made to Order Software Corporation Logo

Testing PHP properly...

I have been wondering, for a little while, how can I properly test my PHP code?! Only my server can run it, right? Well, no, there is CLI. Okay, but how can I make that work in there?

The best answer I’ve got so far: simpletest. This PHP library let you write a test a la C++. You simply create a class derived from a SimpleTest class, and voilà. You are done. Well… you still have to implement test functions. But that is still a breeze.

I used this library to test the PHP eFax classes and got about 4 bugs out (not too bad, considering I wrote over 1,000 lines of code and documentation!) The only thing that it cannot catch are internal errors such as a syntax error and some other low level errors.

If you plan to write a large and complete application in PHP, I strongly suggest that you use a tool like SimpleTest to make sure that your code is really robust. It is not only much less trouble, it will make your application that much more secure.