Over on his blog, Michelangelo van Dam – the leader of the ZendCon UnCon ’12 – has posted the latest in a series of posts about things he learned attending the ZendCon UnCon. This latest post is how he implemented the idea of using fixtures and PHPUnit to test databases.
Here’s a quick sample to wet your whistle.
In my previous post I already mentioned Sebastian Jerzy Wilczyński (@dj_sebastian_w) and his uncon session “Unit Testing for Databases using fixtures and phpunit”. It made me wonder how much difference it would make if you use fixtures instead of testing database interactions using predefined sets of data.
Since I work a lot with Zend Framework I was looking at how I could use fixtures and mock objects to follow Sebastian’s guidelines. So I gave it a try. This is what I came up with.
Like most of Mike’s articles, this article is long on the HOW and long on the WHY. He doesn’t leave you hanging about why you want to do this, nor does he fail to show you exactly how. Since Mike is a Zend Framework developer, everything he shows is centered around projects using Zend Framework.