The Big Unit Testing Discussion Thread™
My background is mainly in C (with C++ or ObjC where necessary). I did a lot of work with signal processing and audio.
In my experience practicing multiple testing styles provides the best results. I found having unit tests to be the most helpful. With two months of PHP under my belt I am ready to dig into more formalized testing for PHP.
Use this thread to share links/thoughts/insights/discussion/questions about testing and PHP with a focus unit testing.
Posted Mar 28, 2012, 9:50 PM UTC
If you're going to be using PHPUnit (a de facto standard?) then I strongly recommend looking into using Phake for creating any test doubles (as opposed to the built-in PHP mock objects).
It may not be apparent at first but the increased flexibility of Phake is near enough to a necessity once your test library grows. The most obvious example that springs to mind is the fact that you can change the behavior of an already-stubbed-method (not possible with PHPUnit mocks). This allows you to build up collections of "canned" test doubles that can be reused across tests.
Thanks for this. I find PHPUnit's mocking to be a bit lacking a lot of the time and I'm never really happy with the syntax. Looking forward to giving Phake a try.