Description
Q | A |
---|---|
Bug report? | sort of |
Feature request? | maybe |
BC Break report? | no |
RFC? | yes/no |
Symfony version | 3.2.8 |
I'm working on Drupal 8 core. Drupal has adopted symfony/phpunit-bridge as a way to catch deprecations. The codebase has a lot of @trigger_error('', E_USER_DEPRECATED)
type code in it.
The problem is that a lot of our PHPUnit-based tests are functional and need to run in isolated processes.
There are two problems:
-
We can't test
@expectedException
in isolated tests. They always fail. -
Errors triggered by
@trigger_error()
never surface in isolated tests.
There are two reasons for this:
For 1 above, SymfonyTestsListener
sets the expectation for the test run before the isolation occurs. Whatever deprecation error is emitted, it happens in another process. When it's done, the 'host' listener then finds no deprecation message so it fails the test.
For 2 above, the problem is that a) Symfony\Bridge\PhpUnit\DeprecationErrorHandler
is never registered in isolation, due to the way the isolation occurs. Also, once you solve the problem of registering the error handler, it fails the test by calling exit(1)
. As it turns out, PHPUnit ignores the return value of the child process, so we never get the fail.
I've written a patch for Drupal that basically overcomes these limitations, but it's effectively a fork of symfony/phpunit-bridge, and it'd be much better not to do that.
You can see the patch here: https://www.drupal.org/node/2870194#comment-12111028
Is there a reason symfony/phpunit-bridge doesn't support isolated tests? I couldn't find a testing policy document to see if the limitation was arbitrary or intentional.