Phpunit: expectExceptionMessageRegExp() has been removed in PHPUnit 9 without a deprecation warning being given in PHPUnit 8

Created on 6 Mar 2020  ·  3Comments  ·  Source: sebastianbergmann/phpunit

| Q | A
| --------------------| ---------------
| PHPUnit version | 9
| PHP version | 7.3
| Installation Method | Composer

Summary

The commit introducing expectExceptionMessageMatches says that expectExceptionMessageRegExp will trigger a warning in 9 and be removed in 10.
But the 9.0 removed the method entirely instead of adding a warning in it. This means that the method got removed without ever reporting a deprecation warning when running tests using it.
And there is no changelog saying that this method is deprecated (the PHPUnit 8 changelog does not talk about deprecating expectExceptionMessageRegExp and the PHPUnit 9 changelog says it is removed).

featurassertion typbug

Most helpful comment

Well, the initial commit intended to add the deprecation warning in 9 (see the linked commit) and remove in 10. That's why there is no warning in 8.4 and 8.5.
The issue is that the removal was done without following the initial plan, and without adding the deprecation warning in 8.x, meaning that there is no warning at all.

The value of the warning is that I can work on the deprecation when seeing the warning (and all at once), rather than having to fix the fatal error due to the removed method, repeating this for each place using it until I don't get a fatal error anymore (or I could search expectExceptionMessageRegExp with my IDE indeed, but then it is not PHPUnit helping me to upgrade and that could justify not using deprecation warnings at all...).
If possible, I think it would make sense to add the warning in 8.5, yes.

All 3 comments

expectExceptionMessageMatches has been added only in 8.4, which is why the PHPUnit 8 announcement does not talk about that at all.

expectExceptionMessageRegExp() was deprecated in PHPUnit 8.4. The fact that this deprecation is not reported when the method is used in annoying, I agree, but is there really value in adding this behaviour in PHPUnit 8.5?

Well, the initial commit intended to add the deprecation warning in 9 (see the linked commit) and remove in 10. That's why there is no warning in 8.4 and 8.5.
The issue is that the removal was done without following the initial plan, and without adding the deprecation warning in 8.x, meaning that there is no warning at all.

The value of the warning is that I can work on the deprecation when seeing the warning (and all at once), rather than having to fix the fatal error due to the removed method, repeating this for each place using it until I don't get a fatal error anymore (or I could search expectExceptionMessageRegExp with my IDE indeed, but then it is not PHPUnit helping me to upgrade and that could justify not using deprecation warnings at all...).
If possible, I think it would make sense to add the warning in 8.5, yes.

Was this page helpful?
0 / 5 - 0 ratings