Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run multiple versions of PHPUnit on the same machine?

I'm using Zend Framework for some projects and want to build up PHPUnit test suites for them. Unfortunately, Zend Framework in it's current version (1.11.x) only supports PHPUnit 3.5. At the same time, I would also like to start working with the Symfony framework, which in turn supports newer versions of PHPUnit. The question then is, how can I run multiple versions of PHPUnit on my dev machine at the same time without having to install separate servers or things like that?

I'm running OS X Lion (10.7) and using apache and php (5.3.10) installed through MacPorts. Ideally, I would like to end up in a situation where I could simply type e.g. phpunit5 in the terminal to execute the 3.5 version and type phpunit6 to execute the 3.6 version, and so on.

like image 713
Jens Wegar Avatar asked May 08 '12 16:05

Jens Wegar


2 Answers

I'd recommend you check this blog post:

  • http://tech.vg.no/2011/11/29/running-multiple-versions-of-phpunit/

For a chef-recipe, check my blog post:

  • http://till.klampaeckel.de/blog/archives/175-Cooking-PHPUnit-and-a-chef-solo-example-on-top.html

In case the links stop working:

  • pear supports an --installroot switch
  • example:

    pear install --installroot /some/path/phpunit34 pear.phpunit.de/PHPUnit-3.4.15

Once install, you may have to add /some/path/phpunit34/usr/bin/ to $PATH or create a symlink to /usr/bin like the blog post illustrates.

HTH

like image 65
Till Avatar answered Oct 20 '22 20:10

Till


The accepted answer works when you install phpunit 3.4, but if you wish to install phpunit 3.5 (which can also be used to unit test within a Zend project, although Zends own tests may not all pass) you have to follow a slightly different path. You will need to install the dependencies for phpunit 3.5 separately before installing phpunit, otherwise some of the dependencies will simply force an install of phpunit 3.6:

Install first (note the -f option, which forces installation of a specific version):

sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.symfony-project.com/YAML-1.0.2
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/PHPUnit_Selenium-1.0.1
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/PHP_Timer-1.0.0
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/Text_Template-1.0.0
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/PHPUnit_MockObject-1.0.3
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/File_Iterator-1.2.3
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/PHP_CodeCoverage-1.0.2
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/DbUnit-1.0.0
sudo pear install -f --installroot /your/path/to/PHPUnit35 pear.phpunit.de/PHPUnit-3.5.15

Then follow the instructions in the link of the accepted answer to change the include path and symlink it correctly.

like image 25
Jens Wegar Avatar answered Oct 20 '22 20:10

Jens Wegar