尝试运行测试时遇到的错误:
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版本,它缺少我需要的Class。所以,我已经完整了。
tl; dr 如何为CakePHP 2.4.x安装PHPUnit 3.6.x?
UPDATE :我检查了最新的CakePHP 2.x版本中使用的是同一个类。另外,我应该提一下,测试在类似但运行较旧的PHPUnit的旧VM上运行正确。
答案 0 :(得分:2)
TL; DR:PHPUnit 3.6不再可用于安装。
PHPUnit 3.6仅作为PEAR包提供。 The PEAR Channel that hosted PHPUnit, pear.phpunit.de, was shut down on December 31, 2014.
答案 1 :(得分:0)
我设法解决了这个问题。由于我无法安装已弃用的PHPUnit版本,因此我从Diff类(diff,diffToArray和longestCommonSubsequence)中删除了缺少的函数,并将它们放入CakeHtmlReporter类中,因为那是唯一引用它们的类。
之后我将PHPUnit_Util_Diff::diff
更改为self::diff
并且它现在正在运行,即使它缺少旧的CSS样式,但我可以忍受。
这不是我问的问题的答案,但也许它可以帮助别人,直到有更好的答案出现。