出现E_USER_DEPRECATED级错误时如何运行Behat测试 [英] How to run Behat tests when there are errors of level E_USER_DEPRECATED

查看:79
本文介绍了出现E_USER_DEPRECATED级错误时如何运行Behat测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Symfony 2.7表单类型,它导致了E_USER_DEPRECATED级的某些错误.此错误不是来自我自己的代码,而是来自vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php.

I have a Symfony 2.7 Form Type which is causing some errors of level E_USER_DEPRECATED. This errors do not come from my own code but from vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php.

在使用Web浏览器的dev模式下,我可以使用上述表格访问页面. WDT确实向我显示了一些DEPRECATED消息,但是该表单确实起作用,该页面返回状态200.

In dev mode using a web browser, I can access the page using said form just fine. The WDT does show me some DEPRECATED messages but the form does work, the page is returned with status 200.

使用Behat 3(带有Behat\Symfony2Extension\Driver\KernelDriverBehat\Mink\Driver\BrowserKitDriver),对相同URL的请求将返回状态500服务器错误.响应中的堆栈跟踪表明DEPRECATED错误导致了异常.

Using Behat 3 (with Behat\Symfony2Extension\Driver\KernelDriver and Behat\Mink\Driver\BrowserKitDriver), the request for the same URL returns a status 500 server error. The stack trace in the response shows that the DEPRECATED errors are causing a exception.

我的Behat配置与 http:中描述的一样简单://docs.behat.org/en/v3.0/cookbooks/1.symfony2_integration.html

My Behat configuration is as plain as described in http://docs.behat.org/en/v3.0/cookbooks/1.symfony2_integration.html

当我按照 https://stackoverflow.com/a/的建议在我的FeatureContext.php文件顶部执行define('BEHAT_ERROR_REPORTING', 0);时9217606/2342504 行为没有改变.

When I do define('BEHAT_ERROR_REPORTING', 0); on top of my FeatureContext.php file as suggested by https://stackoverflow.com/a/9217606/2342504 there is no change in behaviour.

经过一些代码扫描后,我猜想在Behat 3中删除了常量BEHAT_ERROR_REPORTING,而改用了RuntimeCallHandler::errorReportingLevel.

After some code scanning, I guess that the constant BEHAT_ERROR_REPORTING is removed in Behat 3 and the RuntimeCallHandler::errorReportingLevel is used instead.

但是我目前还不知道如何配置或设置RuntimeCallHandler::errorReportingLevel.

Yet I currently have no idea how to configure or set RuntimeCallHandler::errorReportingLevel.

推荐答案

所以我明白了.该文件为我提供了必需的提示: https://github .com/Behat/Behat/blob/master/features/error_reporting.feature#L100-L101

So I got it. This file gave me the required hint: https://github.com/Behat/Behat/blob/master/features/error_reporting.feature#L100-L101

要获得所需的整数,我使用了php -r "echo E_ALL & ~E_USER_DEPRECATED;",得到了16383.所以我把它放到我的behat.yml:

To get the required integer, I used php -r "echo E_ALL & ~E_USER_DEPRECATED;" which yielded 16383. So I put this into my behat.yml:

    calls:
        error_reporting: 16383

此后,Behat最终没有中断,但确实显示了难看的异常痕迹.因此,在类定义之前,我将对FeatureContext.php中的error_reporting的调用放回去:

After that Behat finally did not break, but it did show ugly exception-traces. So I put back the call to error_reporting in FeatureContext.php, right before the class definition:

error_reporting(error_reporting() & ~E_USER_DEPRECATED);

现在Behat忽略了E_USER_DEPRECATED级的所有错误,我想我会一直保持这种状态,直到我开始使用Symfony 3.

Now Behat ignores all errors of level E_USER_DEPRECATED and I guess I will keep it that way until I start using Symfony 3.

这篇关于出现E_USER_DEPRECATED级错误时如何运行Behat测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆