How to run Behat tests when there are errors of level E_USER_DEPRECATED

社会主义新天地 提交于 2019-12-01 09:46:12

问题


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.

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.

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.

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

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.

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

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


回答1:


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

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

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);

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.



来源:https://stackoverflow.com/questions/31050716/how-to-run-behat-tests-when-there-are-errors-of-level-e-user-deprecated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!