Zend_Test_PHPUnit_Constraint_DomQuery::evaluate() 的声明应该与 PHPUnit_Framework_Constraint::evaluate() 的声明兼容

发布于 2024-12-20 03:32:19 字数 2593 浏览 3 评论 0原文

我正在尝试使用 PHPUnit 3.6.4 对我的 Zend Framework 应用程序进行单元测试。当我在命令提示符中尝试此命令时,出现以下错误。

C:\xampp\htdocs\testsample\tests>phpunit --configuration phpunit.xml
PHPUnit 3.6.4 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\testsample\tests\phpunit.xml

←[31;1mE←[0m←[31;1mE←[0m..

Time: 0 seconds, Memory: 10.00Mb

There were 2 errors:

1) IndexControllerTest::testIndexWithMessageAction
Declaration of Zend_Test_PHPUnit_Constraint_DomQuery::evaluate() should be compatible         
with that of PHPUnit_Framework_Constraint::evaluate()

C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\Constraint\DomQuery.php:40
C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\ControllerTestCase.php:512
C:\xampp\htdocs\testsample\tests\application\controllers\IndexControllerTest.php
:14
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:925
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:787
C:\xampp\php\PEAR\PHPUnit\Framework\TestResult.php:649
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:734
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:772
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:745
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:705
C:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php:325
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:187
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:125
C:\xampp\php\phpunit:44

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

C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\Constraint\ResponseHeader.php:400

C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\ControllerTestCase.php:769
C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\ControllerTestCase.php:769
C:\xampp\htdocs\testsample\tests\application\controllers\IndexControllerTest.php
:22
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:925
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:787
C:\xampp\php\PEAR\PHPUnit\Framework\TestResult.php:649
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:734
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:772
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:745
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:705
C:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php:325
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:187
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:125
C:\xampp\php\phpunit:44

←[37;41m←[2KFAILURES!
←[0m←[37;41m←[2KTests: 4, Assertions: 10, Errors: 2.
←[0m←[2K
Generating code coverage report, this may take a moment.

为什么我会收到此错误?我到底做错了什么?请帮我

I am trying to unit test my Zend Framework application using PHPUnit 3.6.4. I get the following error when i try this command in my command prompt.

C:\xampp\htdocs\testsample\tests>phpunit --configuration phpunit.xml
PHPUnit 3.6.4 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\testsample\tests\phpunit.xml

←[31;1mE←[0m←[31;1mE←[0m..

Time: 0 seconds, Memory: 10.00Mb

There were 2 errors:

1) IndexControllerTest::testIndexWithMessageAction
Declaration of Zend_Test_PHPUnit_Constraint_DomQuery::evaluate() should be compatible         
with that of PHPUnit_Framework_Constraint::evaluate()

C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\Constraint\DomQuery.php:40
C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\ControllerTestCase.php:512
C:\xampp\htdocs\testsample\tests\application\controllers\IndexControllerTest.php
:14
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:925
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:787
C:\xampp\php\PEAR\PHPUnit\Framework\TestResult.php:649
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:734
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:772
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:745
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:705
C:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php:325
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:187
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:125
C:\xampp\php\phpunit:44

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

C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\Constraint\ResponseHeader.php:400

C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\ControllerTestCase.php:769
C:\xampp\htdocs\hive\library\Zend\Test\PHPUnit\ControllerTestCase.php:769
C:\xampp\htdocs\testsample\tests\application\controllers\IndexControllerTest.php
:22
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:925
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:787
C:\xampp\php\PEAR\PHPUnit\Framework\TestResult.php:649
C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php:734
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:772
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:745
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php:705
C:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php:325
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:187
C:\xampp\php\PEAR\PHPUnit\TextUI\Command.php:125
C:\xampp\php\phpunit:44

←[37;41m←[2KFAILURES!
←[0m←[37;41m←[2KTests: 4, Assertions: 10, Errors: 2.
←[0m←[2K
Generating code coverage report, this may take a moment.

Why am i getting this error? What is that I've done wrong? Please help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

韬韬不绝 2024-12-27 03:32:19

目前,Zend Framework 1 应用程序(可能在相当长的一段时间内)只能使用 PHPUnit 3.5.x 才能正常运行。

请参阅将 phpunit 3.6 降级至 3.5.15 了解如何降级到3.5

Zend Framework 2 将再次支持当前版本的 PHPUnit

Zend Framework 1 applications currently, and possibly for quite some time, only function properly using PHPUnit 3.5.x.

Please see downgrade phpunit 3.6 to 3.5.15 on how to downgrade to 3.5.

Zend Framework 2 will support the current version of PHPUnit again.

枕梦 2024-12-27 03:32:19

您可以使用 phpdoc @expectedException 命令抑制版本不兼容错误:

/**
 * test bad url
 * @requires PHPUnit 3.5.15
 * @expectedException PHPUnit_Framework_Error_Notice
 * // Zend Framework 1.X cannot use anything greater than PHPUnit 3.5.15
 * */
public function test_InvalidUrl_wrong_action()
{
    $this->dispatch('/index/fake');
    $this->assertController('error','should be the error controller');
    $this->assertAction('error','should be the error action');
    $this->assertResponseCode(200);
}

You can suppress the version incompatibility error using the phpdoc @expectedException command:

/**
 * test bad url
 * @requires PHPUnit 3.5.15
 * @expectedException PHPUnit_Framework_Error_Notice
 * // Zend Framework 1.X cannot use anything greater than PHPUnit 3.5.15
 * */
public function test_InvalidUrl_wrong_action()
{
    $this->dispatch('/index/fake');
    $this->assertController('error','should be the error controller');
    $this->assertAction('error','should be the error action');
    $this->assertResponseCode(200);
}
明天过后 2024-12-27 03:32:19

从来没想过我会回答一个 2 年前的帖子,我遇到了同样的问题并发现 这个 网站由一位修改了 Zend 库的绅士创建,它对我有用(我无法降级......)
希望它能帮助别人:-)

Never thought I will answer a 2 year old post, I encountered the verry same issue and found this site by a gentleman who modified the Zend library and it worked for me (I couldn`t downgrade...)
Hope it will help somebody :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文