How to Downgrade PHPUnit 3.6 to 3.5.15

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!

This entry was posted in Random Thoughts & Going Ons. Bookmark the permalink.

31 Responses to How to Downgrade PHPUnit 3.6 to 3.5.15

  1. penfold says:

    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

  2. Sam S says:

    Yep that worked for me

    sudo pear install phpunit/Text_Template-1.0.0

    will fail since a newer version is installed but other than that (near insignificant) all is well
    now to try this on ubuntu too

  3. Hey MAN, Thanks for this! Was struggling for last 3 days with some warnings and errors… brrrrrr…..

  4. Mel says:

    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! :D

  5. Scott Rankin says:

    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.

  6. Sascha says:

    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

  7. Nick says:

    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

  8. Sameer says:

    One helpful step…

    pear clear-cache

  9. Pingback: How I write my Wordpress Plugins with Classes | Greg Freeman

  10. Clearing the Pear Cache helps, also in summary:

    a) Text_Template has to be uninstalled before Mock_Object which it depends on

    b) Token_Stream also has to be uninstalled as version 1.0.1 has to be installed before Code_Coverage which installs 1.1.1 as Scott put it

    c) Text_Template has to be installed before Mock_Object which will install the 1.1.1

    The final command listing that worked for me is (I am on Windows so I just added sudo before pear for *nix):


    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 uninstall phpunit/PHP_TokenStream

    sudo pear clear-cache

    sudo pear install pear.symfony-project.com/YAML-1.0.2
    sudo pear install phpunit/PHPUnit_Selenium-1.0.1
    sudo pear install phpunit/Text_Template-1.0.0
    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_TokenStream-1.0.1
    sudo pear install phpunit/PHP_CodeCoverage-1.0.2
    sudo pear install phpunit/DbUnit-1.0.0
    sudo pear install phpunit/PHPUnit-3.5.15

  11. Pingback: PHPUnit and ZendFramework 1.x | BinarySputnik's Blog

  12. Syam.s says:

    Thanks for the Post It worked fine ..
    @Stephen.
    Thanks for the script :)

  13. Rodrigo Machado says:

    +1 that got thinks to work with @Stephen´s recipe! txs for Dusty and everybody else that helped too

  14. Ashwin says:

    It worked fine on mac osx lion
    Thanks guys
    Thank you.

  15. Elliot says:

    Thank’s so much for this, it was a nightmare before I found this!

    If pear gives you any grief about a newer version being installed despite giving it a specific version, instead use
    sudo pear install -f phpunit/YourPackage...

  16. isha naik says:

    I have installed all dependencies of phpunit and tried running functional test cases but m getting following error:
    PHP_Invoker_TimeoutException: Execution aborted after 1 second

    Unit test cases runs well. Pls suggest me some solution.

  17. Leonardo Cidral says:

    does not work … I have been trying for days without success …

    Mac OS X 10.7.4
    Mamp 2.0.5
    NetBeans IDE 7.1.2 (Build 201204101705)

  18. martin says:

    Wow, really great!!

  19. Pingback: Setting up Kohana 3.2 unittest module - Danger, Will Robinson!

  20. Thanks heaps,

    I’ve downgraded per your guide because I like to see test output as they are executing and 3.6 removes all capacity to see that, so it looks like I’ll run on 3.5.15 until I can be bothered to patch my install of newer versions.

    Woohoo!

  21. Angelin says:

    Hey man this posts saved me from losing my more time after wasting a day and get into unit test process. I didnt knew that latest 3.6 verison was the problema as I was a newbie and I directly started from 3.6.

  22. Sergey says:

    Thanks a lot! Helped!

  23. Sandy says:

    I have issues with this. I get to the point where I want to install PHP_CodeCoverage-1.0.2

    I get the following error:
    phing/phing requires package “phpunit/PHP_CodeCoverage” (version >= 1.1.0), downloaded version is 1.0.2.

    First of all I don’t know to which version I’d have to downgrade phing to enable me to install PHP_CodeCoverage-1.0.2.
    Second: I need phing 2.4.5 for Propel => http://www.propelorm.org/documentation/01-installation

    Damn! :|
    Anybody ever ran into those problems?

  24. Jon Roig says:

    Super helpful… thanks!

  25. Pingback: Installing PEAR, cURL, Selenium, and PHPUnit on Windows – Steven George's Blog

  26. Joel says:

    It doesn’t work for me. I try this:

    $ sudo pear uninstall phpunit/PHPUnit

    and I get:

    unknown channel “phpunit” in “phpunit/PHPUnit”

  27. Gordon says:

    Thank you for this.

    Best solution for me was the script in Stephen S. Musoke’s post.

  28. wzwz says:

    I got the following error on ubuntu 12.10:
    “Unknown remote channel: components.ez.no”

    I had to run this to add the channel

    sudo pecl channel-discover components.ez.no

  29. I also had to run pear uninstall phpunit/PHP_Invoker

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>