Unit testing Zend Framework 1 – Rob Allen's DevNotes

:

: 4

As part of our release process for Zend Framework 1.12, I've been working through the unit tests and running them on PHP 5.2.4 as it seems that recent changes weren't being tested with that version. This isn't totally surprising as Open Source contributors are, almost by definition, interested in new things and so are much more likely to be running PHP 5.4 rather than 5.2! This is, of course, a compelling reason for using continuous integration and I'm quite excited with Travis-CI and we are using it with ZF2.

Installing PHPUnit 3.4

The first challenge that I encountered was that ZF1's unit test are not compatible with PHPUnit 3.6. As there are over 14,000 ZF1 unit tests which have been written since 2006, there hasn't been much enthusiasm for rewriting them to be PHPUnit 3.6 compatible. (However, if someone wants to volunteer, please contact me!)

As I have PHPUnit 3.6 installed for testing other projects, I needed to install PHPUnit 3.4 side-by-side with version 3.6 This turns out to be relatively easy and has been documented by Christer Edvartsen in his article Running Multiple Versions of PHPUnit.

I ran into one problem with his instructions though and needed this code to be added to the top of phpunit:

1

2

3

4

5

6

7

8

9

10

11

12

13

// For OS X 10.7

set_include_path(implode(PATH_SEPARATOR,array(

__DIR__.'/../share/php',

'/usr/share/php',

get_include_path()

)));

// Or for OS X 10.8

set_include_path(implode(PATH_SEPARATOR,array(

__DIR__.'/../lib/php/pear',

'/usr/lib/php/pear',

get_include_path()

)));

Having done this though, PHPUnit 3.4 works correctly and we can run ZF1 unit tests.