Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Working on #3031379: Add a new test type to do real update testing I came across this.
If your test has no test methods, then DeprecationListenerTrait::registerErrorHandler()
can't reflect on the results object to add another listener (because there is not a results object). This means your test result is always THE ERROR HANDLER HAS CHANGED!
This is obviously mitigated by the fact that you should have test methods in your test class, but we can add some DX happiness through defensive coding.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#3 | 3052625_3.patch | 1.47 KB | Mile23 |
Comments
Comment #2
Mile23Comment #3
Mile23Comment #4
Mile23Comment #5
alexpottFair enough. I manually tested this by removing all the tests from a unit test and saw it error as described in the issue summary. With the patch attached you still get the THE ERROR HANDLER HAS CHANGED! notice but you don't get a stack trace so this looks good to go. There's not much we can do about the notice and it's not important anyway because there are no tests which is an error anyways.
Comment #6
Mile23Yah the use case for this is when you change test method names to
te_stSomething()
for debugging, and then you get the handler changed error. :-)Comment #9
Gábor HojtsyThanks, committed.