PHPUnit弃用警告未通过测试

PHPUnit弃用警告未通过测试

本文介绍了PHPUnit弃用警告未通过测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在PHP 5.3.29安装上使用PHPUnit 4.8。我们应用程序中的某些代码使用了已弃用的 mysql _ * 功能,PHPUnit将这些实例的弃用通知转换为异常,从而使那些特定的测试用例失败。 p>

现在我已经在config.xml中包含了 convertErrorsToExceptions = false ,但这似乎并没有



有人可以帮忙弄清这里可能发生的事情吗?



欢呼声!



编辑:在

解决方案

convertErrorsToExceptions = false 配置选项仅控制 E_ERROR 到异常的转换。不过,弃用表示为 E_DEPRECATED



A 的转换的配置选项。这将在PHPUnit 6.2中添加。这不会反向移植到您正在使用的PHPUnit版本的PHPUnit 4.8,因为该版本已到使用寿命。



在您的引导脚本中,您可以设置 PHPUnit_Framework_Error_Deprecated :: $ enabled = false; ,但是,这将禁止将 E_DEPRECATED 转换为异常。


I'm using PHPUnit 4.8 on a PHP 5.3.29 install. Some of the code in our application makes use of the deprecated mysql_* functionality, and PHPUnit converts the deprecation notices of these instances to exceptions and in turn fails those specific testcases.

Now I've already included the convertErrorsToExceptions="false" in the config.xml but this doesn't seem to help as it's still happening.

Can anyone help shed some light on what might be happening here?

Cheers!

EDIT: Added example files on gist.github.com

解决方案

The convertErrorsToExceptions="false" configuration option only controls the conversion of E_ERROR to exceptions. A deprecation is represented as E_DEPRECATED, though.

A configuration option is missing for controlling the conversion of E_DEPRECATED to exceptions. This will be added in PHPUnit 6.2. This will not be backported to PHPUnit 4.8, the version of PHPUnit you are using, as that version has reached its end of life.

In your bootstrap script you can set PHPUnit_Framework_Error_Deprecated::$enabled = false;, though, which will disable the conversion of E_DEPRECATED to exceptions.

这篇关于PHPUnit弃用警告未通过测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:40