从 Zend Studio 8 运行 phpUnit 测试套件时出现奇怪的错误
Zend Studio 8 有 phpUnit 集成和专用视图,这很棒,所以我想使用它...但是:
当我在命令行上运行 phpunit.xml 时,测试执行得很好,当我尝试在 Zend Studio 中运行 phpunit.xml 作为单元测试,我收到以下致命错误:
致命错误:未捕获的异常 带有消息的“PHPUnit_Framework_Error” '分配new的返回值 C:\Program 中的引用已被弃用 文件 (x86)\Zend\ZendServer\bin\PEAR\PEAR\Config.php:650
堆栈跟踪:
#0 C:\Program 文件 (x86)\Zend\ZendServer\bin\PEAR\PEAR\RunTest.php(22): ZendPHPUnitErrorHandler->句柄(8192, '分配 r...', 'C:\Program 文件...',650,数组)
#1 C:\程序 文件 (x86)\Zend\ZendServer\bin\PEAR\PEAR\RunTest.php(22): require_once()
#2 C:\程序文件 (x86)\Zend\ZendServer\bin\PEAR\PHPUnit\Extensions\PhptTestCase.php(49): require_once('C:\程序文件...')
#3 C:\Program Files (x86)\Zend\Zend 工作室 - 8.0.0\plugins\com.zend.php.phpunit_8.0.0.v20101001-0100\resources\ZendPHPUnit.php(103): require_once('C:\程序文件...')
#4 {main} 抛出在 C:\Program Files 中 (x86)\Zend\ZendServer\bin\PEAR\PEAR\Config.php 第 650 行
我真的不知道这意味着什么...为什么 PEAR 配置中的某些已弃用的代码会阻止我的测试运行?
[编辑] 一些附加信息:
我的同事既没有安装 PEAR 也没有安装 phpunit,可以从 Zend Studio 8 运行单元测试,但他不能从 CLI 运行任何单元测试。因此,Zend Studio 似乎不仅与 phpUnit 集成,而且还与它的一个版本捆绑在一起。我想要最新版本,这就是为什么我安装了 PEAR,然后通过 PEAR 安装了 phpUnit。因此,Zend Studio 的 phpUnit 库已经过时,我不得不用 Zend Forum 用户的版本替换 Zend Studio 插件文件夹中的文件“ZendPHPUnit.php”。这导致正确包含 phpUnit 类和当前问题。 [/编辑]
Zend Studio 8 has phpUnit integration and a dedicated view, which is great, so I would like to use it... but:
When I run my phpunit.xml on the command line, the tests are executed just fine, when I try to run phpunit.xml in Zend Studio as unit test, I get the following fatal error:
Fatal error: Uncaught exception
'PHPUnit_Framework_Error' with message
'Assigning the return value of new by
reference is deprecated' in C:\Program
Files
(x86)\Zend\ZendServer\bin\PEAR\PEAR\Config.php:650
Stack trace:
#0 C:\Program Files
(x86)\Zend\ZendServer\bin\PEAR\PEAR\RunTest.php(22):
ZendPHPUnitErrorHandler->handle(8192,
'Assigning the r...', 'C:\Program
File...', 650, Array)
#1 C:\Program
Files
(x86)\Zend\ZendServer\bin\PEAR\PEAR\RunTest.php(22):
require_once()
#2 C:\Program Files
(x86)\Zend\ZendServer\bin\PEAR\PHPUnit\Extensions\PhptTestCase.php(49):
require_once('C:\Program File...')
#3
C:\Program Files (x86)\Zend\Zend
Studio -
8.0.0\plugins\com.zend.php.phpunit_8.0.0.v20101001-0100\resources\ZendPHPUnit.php(103):
require_once('C:\Program File...')
#4
{main} thrown in C:\Program Files
(x86)\Zend\ZendServer\bin\PEAR\PEAR\Config.php
on line 650
I really don't have a clue what that means... why should some deprecated code in the PEAR config keep my tests from running?
[edit]
Some additional information:
My colleague who has neither PEAR nor phpunit installed, can run unit tests from Zend Studio 8 just fine but he can't run any from the CLI. So it seems that Zend Studio not only integrates with phpUnit but comes bundled with a version of it. I wanted the newest version and that's why I installed PEAR and then via PEAR I installed phpUnit. As a consequence, the phpUnit library of Zend Studio was outdated and I had to replace the file 'ZendPHPUnit.php' in the Zend Studio plugin folder with a version of a Zend Forum user. This lead to correct inclusion of the phpUnit classes and the current problem.
[/edit]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PEAR\Config.php 中的第 650 行
会引发
E_DEPRECATED
消息取决于您是否启用了 error_reporting 以包含该级别。PHPUnit
和ZendPHPUnit
的错误处理程序会将它们转换为PHPUnit_Framework_Exceptions
。因为 PHP 会在编译时引发
E_DEPRECATED
,所以抑制这些错误的唯一方法是在 php.ini 中。我的假设是,从 CLI 运行的 PHPUnit 使用的 php.ini 与 Zend Studio 不同,并且该 php.ini 中的错误级别不足以引发E_DEPRECATED
。如果您可以提供一个可重现的示例,我们也许能够更理解它。无论如何,请尝试将 PEAR 安装更新到最新版本。
Line 650 in PEAR\Config.php does
This will raise an
E_DEPRECATED
message depending on whether you have enabled error_reporting to include that level. The error handlers ofPHPUnit
andZendPHPUnit
will convert those toPHPUnit_Framework_Exceptions
.Because PHP will raise
E_DEPRECATED
already at compile time, the only way to suppress these errors is in php.ini. My assumption is, that your PHPUnit you run from CLI is using a different php.ini than that your Zend Studio and in that php.ini the error level is not low enough to raiseE_DEPRECATED
.If you can provide a reproducable example, we might be able to make more sense of it. In any case, try to update your PEAR installation to the latest version.