PHPUnit Snapshot Assertions – a way to test without writing actual test cases

phpunit-snapshot-assertions – is an interesting addition to the PHPUnit assertions which allows testing against previously created snapshots.  This is particularly useful for testing the outputs of API end-points, format conversion functions, and the like.  Instead of testing the actual functionality, these assertions allow to compare the output of the current test run with the known good output of a previously created snapshot.

This works well for generic text, but even better for widely used formats like JSON and XML, where, in case of a failed assertion, a meaningful difference can be provided.

Here is a blog post providing some more details on philosophy and methodology.

Religious programming

Here is a snippet of discussion I had with a colleague today.  I thought it was funny:

[2:59 PM] Him: this is your prob:
[2:59 PM] * Him sent file IMG_04092012_145925.png.
[2:59 PM] Him: “&” is not valid char in xml
[3:00 PM] Me: hmm
[3:00 PM] Me: how do you know? :)
[3:00 PM] Him: i prayed to the lord and he showed me the way
[3:00 PM] Him: you didn’t, right?
[3:01 PM] Me: I have a different lord apparently :)
[3:01 PM] Him: your lord is not a programmer!
[3:01 PM] Me: no, my lord can parse & in xml just fine … your lord is a pussy :)
[3:02 PM] Him: lol!!

Upgraded to WordPress 1.5.1.3

I have finally upgraded to this blog to WordPress 1.5.1.3. A couple of security issues with XML RPC are fixed by this release. I was a bit slow, since the fixes were released for over a week now, but not to worry – my PHP installation already had all the fixes for XML RPC installed.

Slashdot is running a story on the issue. One of the comments shows an easy way of upgrading PEAR that not everyone might be familiar with:

pear clear-cache
pear upgrade XML_RPC