I was assigned a simple task a few days ago. I had to write a simple string check class, then use it somewhere in the Big Application of ours. I started by writing a unit test and it worked (I said the check was simple. I'm not bragging here). Since I had finished sooner than I expected, I thought about writing a unit test for the class that would use the check, because there was none.
Soon it became obvious that the idea wasn't so great: it was impossible to create an object without some magical, not documented pre-requisites. For instance, the class used heavily session data and an array of 3 different objects passed 3 times by reference, serialized, restored, extended, lost, found, stabbed, shot, recreated from scratch, and the array was conveniently called "data".
When my unit test constructor achieved 40 lines of code, the whole thing seemed to finally live long enough to perform a few simple tricks. I felt like a magician muttering spells and drawing pentagrams around a portal to summon the beast, whose only trick was to make cold coffee. The effort wasn't worth it, but I was so far into it, that I didn't want to give up half way through.
And then I stumbled about this nicely documented variable used as some sort of identifier:
class Block {
[snipped some 50 variables]
/*
* don't know what it does... ask Sophie
*/
var $aramis = $_SESSION['aramis'];
[snip]
}
Still no sign of Porthos or Athos, but I'm pretty sure they're somewhere near.