0

Error that I'm getting when trying to run tests:

Fatal error: Class 'PHPUnit_Util_Diff' not found in Cake/TestSuite/Reporter/CakeHtmlReporter.php on line 267

As per this question, and the answers there, I need to install PHPUnit 3.6.x to avoid the missing Class error. How can I install this, now deprecated, version?

I've tried using composer like this:

composer global require "phpunit/phpunit=3.6.*"

But I get the following error

 Problem 1
    - The requested package phpunit/phpunit could not be found in any version, there may be a typo in the package name.

I've tried PEAR with this command:

sudo pear install phpunit/PHPUnit-3.6.12

but I get this error:

Attempting to discover channel "phpunit"...
Attempting fallback to https instead of http on channel "phpunit"...
unknown channel "phpunit" in "phpunit/phpunit-3.6.12"
invalid package name/package file "phpunit/phpunit-3.6.12"
install failed

I have found an answer here which points me to dereuromark's plugin, which is deprecated and suggests that I use composer since the pear channel for PHPUnit has been shutdown. Not to mention that it's version 3.7.x, which is missing the Class I need. So, I've come full circle.

tl;dr How do install PHPUnit 3.6.x for the CakePHP 2.4.x?

UPDATE: I checked that the same class is used in the latest CakePHP 2.x version. Also, I should mention that test ran correctly on a similar, but older VM that had the older PHPUnit installed.

Community
  • 1
  • 1
Nick Zinger
  • 1,174
  • 1
  • 12
  • 28
  • 1
    The class is there just fine in the [**3.7**](https://github.com/sebastianbergmann/phpunit/blob/3.7.38/PHPUnit/Util/Diff.php) as well as the [**3.6**](https://github.com/sebastianbergmann/phpunit/blob/3.6.12/PHPUnit/Util/Diff.php) branch. – ndm Feb 06 '15 at 16:18
  • @ndm oh man, I totally missed it... I managed to mix up the class the other SO question was missing (which is missing in 3.7) with the ones I needed. Ok, an update will fix that. – Nick Zinger Feb 06 '15 at 21:17

2 Answers2

2

TL;DR: PHPUnit 3.6 is no longer available for installation.

PHPUnit 3.6 was only ever available as a PEAR package. The PEAR Channel that hosted PHPUnit, pear.phpunit.de, was shut down on December 31, 2014.

Sebastian Bergmann
  • 7,837
  • 1
  • 27
  • 35
  • Thanks for the reply! I see that even 3.7 has what I need, I shouldn't have blindly followed the other SO question/answer... – Nick Zinger Feb 06 '15 at 21:16
0

I managed to workaround the issue. Since I wasn't able to install the deprecated PHPUnit version, I took the missing functions from the Diff class(diff, diffToArray and longestCommonSubsequence) and put them into the CakeHtmlReporter Class, since that was the only one referencing them.

After that I changed PHPUnit_Util_Diff::diff to self::diff and it's working now, even though it's missing the old CSS styles, but I can live with that.

It's not the answer to the question I asked, but maybe it can help someone else, until a better answer comes along.

Nick Zinger
  • 1,174
  • 1
  • 12
  • 28