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

I have a Symfony 2.7 form type that causes some E_USER_DEPRECATED level E_USER_DEPRECATED . These 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 the specified form. WDT shows me some DEPRECATED messages, but the form works, the page returns with a status of 200.

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

My Behat configuration is as simple as described at 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/3/3/3/3/3/3/16/ , no behavior changes.

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

However, I do not know how to configure or install RuntimeCallHandler::errorReportingLevel .

+1
source share
1 answer

So, I get it. This file gave me the necessary 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 gave 16383 . So I put this in my behat.yml :

  calls: error_reporting: 16383 

After this, Beat finally did not break, but he showed ugly exceptions, traces. So I returned the error_reporting call to FeatureContext.php , right before the class definition:

 error_reporting(error_reporting() & ~E_USER_DEPRECATED); 

Now Behat ignores all errors of the E_USER_DEPRECATED level, and I think I will support it this way until I start using Symfony 3.

+3
source

Source: https://habr.com/ru/post/1395315/


All Articles