For a while now, I’ve had a renewed interesting testing applications – unit, functional, performance, etc – and have been learning all I can about the software you can use to run these tests. Obviously, one of the mainstays of the PHP world is PHPUnit for unit testing. There’s a few others out there that are good for other kinds of testing – too many to name (and lots that aren’t written in PHP).
Lately, though, I’ve been looking more at testing the frontend of applications and their flow. I started looking around at the current testing tools and found some I wanted to use, but I wanted more to know how they worked. So, as an exercise, I started on Frisk, a light-weight simple testing framework that has some of the basics of functionally testing, nothing fancy though. Oh, and of course it’s open sourced so you can take a look at the work behind it too.
It’s not a complete testing tool, but it does work. I’ve thrown together a simple example of how I’ve used it to test two things on the Joind.in site – the homepage content and the result of a login:
When this file is dropped in the “tests” directory and the “frisk” executable is run, it’ll execute these tests and check the results of those requests. The “ji-enygma.localhost” is a reference to my local Joind.in instance. The results are spit back out as a PHP array that reports the results of each part of the test (pass/fail) split out by test function name and action/assert result:
Start! ===================== ending status: Array ( [JoindinTest] => Array ( [testHomepageContent] => Array ( [ActionGet] => Array (  => pass  => ) [AssertContains] => Array (  => pass  => ) ) [testValidLogin] => Array ( [ActionGet] => Array (  => pass  => ) [ActionSubmitform] => Array (  => pass  => ) [AssertContains] => Array (  => fail  => AssertContains: Term not found ) ) ) )
The project is hosted on Github so you can grab the source, fork it and play with the assertions and actions (or helpers!) and check out the project wiki for complete details on what the project has to offer.