UPDATE: It was merged to ZF as a PR #214. All you need to do is to update Zend Framework.
Great Zend Framework apps definitely should have automated tests. ZF helps you with that by providing PHPUnit extension which allows you to test controllers - adds special asserts for response and DOM queries. But there is a big downside - it works only with PHPUnit 3.4. I agree with the goal to maintain ultimate backwards compatibility, but I prefer to use latest versions of my tools. So I have latest PHPUnit installed for testing other apps and 3.4 for testing ZF1 apps (see this tutorial to install PHPUnit 3.4 and the latest one). I hate having to set up two PHPUnits after reinstall (and setting them up on CI server).
So I decided to fix the Zend_Test (for myself) to work with latest PHPUnit. I originally thought I would have to do it myself, but then I found this patch (thanks!) which I have applied to a branch in my fork of ZF1.
After that, I needed to fix my tests to work with latest PHPUnit. Luckily it meant just replacing assertType()
with assertInstanceOf()
.
Shortly, you need to do this:
- Fix the Zend_Test
- Fix your tests
- Get rid of the old PHPUnit 3.4
- Profit
After that the tests run fine with latest PHPUnit.
If you have any questions or trouble fixing ZF1 and tests for latest PHPUnit, feel free to ask in the comments.