The newest release of PHPUnit 3.6 broke my unit test process in PHPStorm. PHPStorm is aware of the issue and is fixing it in the next update. However, in order to run my unit tests in the meantime I had to downgrade from PHPUnit 3.6 to 3.5.15, which was harder than it should’ve been.
If you try installing PHPUnit-3.5.15 first, you’ll find PEAR forces you to install 3.6. The way around this is installing the old versions of all of the PHPUnit dependencies.
First you need to uninstall PHPUnit 3.6 and all of it’s dependencies.
sudo pear uninstall phpunit/PHPUnit
sudo pear uninstall phpunit/DbUnit
sudo pear uninstall phpunit/PHP_CodeCoverage
sudo pear uninstall phpunit/File_Iterator
sudo pear uninstall phpunit/Text_Template
sudo pear uninstall phpunit/PHP_Timer
sudo pear uninstall phpunit/PHPUnit_MockObject
sudo pear uninstall phpunit/PHPUnit_Selenium
sudo pear uninstall pear.symfony-project.com/YAML
Next install these specific versions of each dependency, in this order, installing PHPUnit-3.5.15 last.
sudo pear install pear.symfony-project.com/YAML-1.0.2
sudo pear install phpunit/PHPUnit_Selenium-1.0.1
sudo pear install phpunit/PHPUnit_MockObject-1.0.3
sudo pear install phpunit/PHP_Timer-1.0.0
sudo pear install phpunit/File_Iterator-1.2.3
sudo pear install phpunit/PHP_CodeCoverage-1.0.2
sudo pear install phpunit/Text_Template-1.0.0
sudo pear install phpunit/DbUnit-1.0.0
sudo pear install phpunit/PHPUnit-3.5.15
Now you should be good to go!

Thanks for posting this, it saved me quite some time figuring out how to downgrade PHPUnit
I ran into a bug in PHPUnit_Selenium-1.0.1 where tests fail with a cryptic message, e.g. ‘Undefined property: WebTest::$name’. This can be resolved by upgrading to 1.0.2:
https://github.com/sebastianbergmann/phpunit/issues/117
Yep that worked for me
sudo pear install phpunit/Text_Template-1.0.0will fail since a newer version is installed but other than that (near insignificant) all is well
now to try this on ubuntu too
Hey MAN, Thanks for this! Was struggling for last 3 days with some warnings and errors… brrrrrr…..
While trying to install phpunit/PHP_CodeCoverage-1.0.2, I get this error. PHPUnit-3.5.15 won’t install without it.
phpunit/PHP_CodeCoverage requires package “channel://components.ez.no/ConsoleTools” (version >= 1.6)
To fix this:
sudo pear channel-discover components.ez.no
sudo pear install channel://components.ez.no/ConsoleTools-1.6
And now you can run sudo pear install phpunit/PHP_CodeCoverage-1.0.2!
Also, make sure you installed File_Iterator-1.3.0 (not 1.2.3), as that’s what PHPUnit-3.5.15 needs.
Everything should work now!
I found the dependency order was slightly awry. I had to uninstall PHPUnit_MockObject before uninstalling Text_Template.
I also found I had to uninstall phpunit/PHP_TokenStream as my system still had 1.1.1 and this resulted in some failures to write a coverage report with an error containing “PHP Fatal error: Class ‘PHP_Token_Stream’ not found in /usr/share/php/PHP/Token/Stream/CachingFactory.php on line 68″
$ sudo pear uninstall phpunit/PHP_TokenStream
uninstall ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.1
And then install a specific version prior to installing CodeCoverage otherwise CodeCoverage would install 1.1.1,
$ sudo pear install phpunit/PHP_TokenStream-1.0.1
I’m on Debian Squeeze.
As Scott Rankin pointed out the order of the uninstall will spawn some errors, so I just iterated through the list a couple of times and called each uninstaller until everything was gone. So that’s no big deal.
A BIG, BIG thank you for posting this. It was extremely helpful to me.
A little side note: phpunit/DbUnit-1.0.3 (instead of 1.0.0) will work too without breaking dependencies
As previously stated, the dependencies won’t fully uninstall the first time through because of the order in which they’re listed in the original post.
This bash script should do the trick:
#!/bin/bash
sudo pear uninstall phpunit/PHPUnit &&
sudo pear uninstall phpunit/DbUnit &&
sudo pear uninstall phpunit/PHP_CodeCoverage &&
sudo pear uninstall phpunit/File_Iterator &&
sudo pear uninstall phpunit/PHP_Timer &&
sudo pear uninstall phpunit/PHPUnit_MockObject &&
sudo pear uninstall phpunit/Text_Template &&
sudo pear uninstall phpunit/PHPUnit_Selenium &&
sudo pear uninstall pear.symfony-project.com/YAML &&
sudo pear install pear.symfony-project.com/YAML-1.0.2 &&
sudo pear install phpunit/PHPUnit_Selenium-1.0.1 &&
sudo pear install phpunit/PHPUnit_MockObject-1.0.3 &&
sudo pear install phpunit/PHP_Timer-1.0.0 &&
sudo pear install phpunit/File_Iterator-1.2.3 &&
sudo pear install phpunit/PHP_CodeCoverage-1.0.2 &&
sudo pear install phpunit/DbUnit-1.0.3 &&
sudo pear install phpunit/PHPUnit-3.5.15
One helpful step…
pear clear-cache
Pingback: How I write my Wordpress Plugins with Classes | Greg Freeman