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!

31 thoughts on “How to Downgrade PHPUnit 3.6 to 3.5.15

  1. 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

  2. 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! πŸ˜€

  3. 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.

  4. 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

  5. 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

  6. 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

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

  8. 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...

  9. 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.

  10. 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)

  11. 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!

  12. 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.

  13. 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?

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

    $ sudo pear uninstall phpunit/PHPUnit

    and I get:

    unknown channel “phpunit” in “phpunit/PHPUnit”

  15. 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

Leave a Reply

Your email address will not be published.