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.
I'd recommend you check this blog post:
For a chef-recipe, check my blog post:
In case the links stop working:
--installroot
switchexample:
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With