Running multiple versions of PHPUnit

The latest version of PHPUnit (3.6.4 at the time of this writing) does not play well with the Zend Framework extensions (Zend_Test_PHPUnit). After asking Matthew Weier O’Phinney about this he answered that they had standardized on PHPUnit-3.4 for ZF1.

Having just upgraded to the latest version of PHPUnit on our servers we were no longer able to test our Zend Framework applications. One option was to downgrade PHPUnit, but since we were already using some of the new features this was not going to happen.

One solution to this problem is to run multiple versions of PHPUnit and use specific versions for specific test suites. Not optimal, but at least it gets the job done.

Installing multiple versions can be accomplished by using the --installroot option to the pear command:

This will install PHPUnit-3.4.15 to /some/path/phpunit34.

You will need to make a small change to one of the installed files to fix the include_path. If you installed the package to /some/path/phpunit34 the file you want to change is /some/path/phpunit34/usr/bin/phpunit. Before the first require_once statement in that file, enter the following code:

The path you need to prepend to PHP’s include_path is different from distro to distro. To see the path your system uses run the following command:

or simply look around in the directory where you installed the specific version of PHPUnit.

The last part of the puzzle is to place a symlink to the file you just edited in /usr/bin. This can be done by running the following command:

To verify that everything works you can run these commands:

Feel free to leave a comment if you see any possible problems with this solution.

Read more from the Software engineering category
SUBSCRIBE TO OUR UPDATES
Menu