As a newcomer to PHP I was puzzled by how to unit test controllers and services when using Silex (if you're wondering, Silex is based on the
Symfony 2 framework and draws a lot of modules from it).
In this post I'll talk about my experiences getting tests going, and how you can setup your own unit tests using
PHPUnit and WebTestCase. I'll start with my initial attempts to test directly against the DB, and the approach that I ultimately found most useful and practical.
I've also created an example Silex project that can be used to try out the various features of PHPUnit. The only prerequisite is PHP 5.4, which comes with most modern OS's. You don't even need Apache
installed to try it out!
06 February, 2014
/