从 Zend Studio 8 运行 phpUnit 测试套件时出现奇怪的错误

发布于 2024-10-28 07:51:02 字数 1408 浏览 4 评论 0原文

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 技术交流群。

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

发布评论

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

评论(1

婴鹅 2024-11-04 07:51:02

PEAR\Config.php 中的第 650 行

$this->_registry['default'] = &new PEAR_Registry(
    $this->configuration['default']['php_dir']
);

会引发 E_DEPRECATED 消息取决于您是否启用了 error_reporting 以包含该级别。 PHPUnitZendPHPUnit 的错误处理程序会将它们转换为 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->_registry['default'] = &new PEAR_Registry(
    $this->configuration['default']['php_dir']
);

This will raise an E_DEPRECATED message depending on whether you have enabled error_reporting to include that level. The error handlers of PHPUnit and ZendPHPUnit will convert those to PHPUnit_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 raise E_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.

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