- Issue created by @tedbow
- Assigned to omkar.podey
- @omkarpodey opened merge request.
- 🇺🇸United States phenaproxima Massachusetts
Well, this is problematic.
Here's the PR where PHPUnit's expectErrorMessage() was removed: https://github.com/sebastianbergmann/phpunit/issues/5062
This PR does not explain the rationale for the change in any helpful way. Sebastian says:
There are no replacements. PHPUnit 10 no longer converts E_* to exceptions, therefore E_* can no longer be expected.
Well, er...okay, then?
@alexpott asked this but has so far received no reply:
what is the recommended way of testing that an error is triggered in PHPUnit 10? If you want to assert that an E_USER_WARNING is thrown by your code what is the best way to do this? Should you replace the error handler as above or is there a better way?
- Status changed to Needs work
almost 2 years ago 7:42pm 8 February 2023 - 🇺🇸United States phenaproxima Massachusetts
Looking into this more closely...I think this worked only by coincidence.
I'm not sure why
$this->expectErrorMessage()
was called, but I suspect it was simply an innocent mistake on the part of whoever wrote that line. Because PHPUnit defines that method, it didn't die with a "call to undefined method" or anything like that.Here's what
$this->expectErrorMessage()
does: https://github.com/sebastianbergmann/phpunit/commit/3812fd713359a21aed38...It's just a thin wrapper around
$this->expectExceptionMessage()
!So, indeed, the validator is legitimately raising a StageValidationException. We are expecting the correct message. We simply are using a deprecated method call to make that happen.
Therefore, all we have to do here is call
$this->expectExceptionMessage()
directly instead, and this problem will go away forever. For clarity and explicitness, we should probably also add a$this->expectException(StageValidationException::class);
beforehand, too. - Assigned to tedbow
- Status changed to Needs review
almost 2 years ago 7:48pm 8 February 2023 - Status changed to RTBC
almost 2 years ago 8:48pm 8 February 2023 - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Yes, core has been using that method for years. 👍
-
phenaproxima →
committed 08281cd7 on 8.x-2.x authored by
omkar.podey →
Issue #3339719 by omkar.podey, phenaproxima, tedbow, Wim Leers: Tests...
-
phenaproxima →
committed 08281cd7 on 8.x-2.x authored by
omkar.podey →
- Status changed to Fixed
almost 2 years ago 8:57pm 8 February 2023 - Issue was unassigned.
Automatically closed - issue fixed for 2 weeks with no activity.