错误:PHPUnit的安装纸为试图运行测试时我得到的CakePHP 2.4
Fatal error: Class 'PHPUnit_Util_Diff' not found in Cake/TestSuite/Reporter/CakeHtmlReporter.php on line 267
按this question,并有答案,我需要安装PHPUnit到3.6.x的避免了丢失的类错误。我如何安装这个现在已过时的版本?
我使用作曲家这样的尝试:
composer global require "phpunit/phpunit=3.6.*"
但我得到以下错误
Problem 1
- The requested package phpunit/phpunit could not be found in any version, there may be a typo in the package name.
我试过PEAR用这个命令:
sudo pear install phpunit/PHPUnit-3.6.12
但我得到这个错误:
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
我找到了一个答案here,它指向dereuromark's plugin,这已弃用,并建议我使用composer,因为PHPUnit的pear通道已关闭。更不用说它是3.7.x版本,它缺少我需要的类。所以,我来了整整一圈。
tl; dr 如何为CakePHP 2.4.x安装PHPUnit 3.6.x?
更新:我检查了在最新的CakePHP 2.x版本中使用了相同的类。另外,我应该提到,测试在一个类似的老版本的虚拟机上正确运行,而旧版本的虚拟机安装了旧的PHPUnit。
这个类在[** 3.7 **](https://github.com/sebastianbergmann/phpunit/blob/3.7.38/PHPUnit/Util/Diff.php)以及[** 3.6 **](https://github.com/sebastianbergmann/phpunit/blob/3.6.12/PHPUnit/Util/Diff.php)分支。 – ndm 2015-02-06 16:18:17
@ndm噢,我完全错过了......我设法混淆了另一个SO问题(缺失3.7)和我需要的问题。好的,更新会解决这个问题。 – 2015-02-06 21:17:56