1

我已经用 Zend Framework 配置了 PHPUnit。当我运行命令时

phpunit --configuration phpunit.xml

我收到失败消息,例如

Declaration of Zend_Test_PHPUnit_Constraint_ResponseHeader::evaluate() should be compatible with that of PHPUnit_Framework_Constraint::evaluate()

我有以下assert功能

$this->assertModule($urlParams['module']);
$this->assertController($urlParams['controller']);
$this->assertAction($urlParams['action']);
$this->assertResponseCode(200);

我搜索了问题并找到了许多相关的解决方案,如此所述。我检查了我的 PHPUnit 版本3.7.9,Zend Framework 1 只能在PHPUnit 3.5.x.

然后我尝试按照此处PHPUnit所述降级。该过程成功运行。但是当我去安装降级版本并运行命令时un-installation

pear install phpunit/PHP_CodeCoverage-1.0.2

它会产生一个错误

phing/phing requires package "phpunit/PHP_CodeCoverage" (version >= 1.1.0). phpunit/PHP_CodeCoverage cannot be installed, Conflicts with installed packages. 

有人告诉我如何处理这种情况?如何使安装的 PHPUnit 版本与 Zend Framework 兼容1.X或如何正确降级我的 PHPUnit?

此致。

4

1 回答 1

0

您始终可以安装 2 个不同的 PHPUnit 实例。安装pear最新版本的 PHPUnit 以开始Phing工作,并使用 Composer 安装 PHPunit 版本 3.5.x - 按照此处的说明。

如果一切都正确完成,您将拥有一个最新版本的系统范围的 PHPUnit,并且在您的项目文件夹中,vendors/bin您将拥有 PHPunit 3.5.x。使用第二个在 ZF1 中构建测试。

于 2012-11-20T10:00:37.413 回答