How to run multiple versions of PHPUnit on one computer?

I use the Zend Framework for some projects and want to create a set of PHPUnit tests for them. Unfortunately, Zend Framework in its current version (1.11.x) only supports PHPUnit 3.5. At the same time, I would also like to get started with the Symfony framework, which in turn supports newer versions of PHPUnit. The question is, how can I run multiple versions of PHPUnit at the same time on my dev machine without installing separate servers or similar things?

I am running OS X Lion (10.7) and using apache and php (5.3.10) installed through MacPorts. Ideally, I would like to be in a situation where I could just type, for example. phpunit5 in the terminal to run version 3.5 and enter phpunit6 to run version 3.6 and so on.

+7
source share
3 answers

I would recommend you check out this blog post:

For a chef recipe, check out my blog post:

If the links stop working:

  • pear supports switch --installroot
  • Example:

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

After installation, you may need to add /some/path/phpunit34/usr/bin/ to $PATH or create a symbolic link to /usr/bin , as shown on the blog.

NTN

+4
source

The accepted answer works when installing phpunit 3.4, but if you want to install phpunit 3.5 (which can also be used for unit test in the Zend project, although not all Zends tests can pass), you should 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 you to install phpunit 3.6:

Install first (note the -f option, which forces the 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 path of inclusion and correctly designate the link.

+1
source

PHPUnit now offers bundled PHAR files for all its versions at https://phar.phpunit.de/

Just download the required version and call them using:

 php phpunit-XYZphar 

(Where XYZ is the PHPUnit version)

PHAR files can be easily flattened to make them system-wide accessible.

0
source

All Articles