- 🇺🇦Ukraine voleger Ukraine, Rivne
There is an update in the issue thread. It suggests throwing exceptions in the custom test error hander and expecting exceptions to assert an error message.
- 🇮🇹Italy mondrake 🇮🇹
@claudiu.cristea for deprecations, we need Symfony PHPUnit-Bridge to become compatible with PHPUnit 10. Or we need to stop using it and look for alternatives. I've started something upstream, https://github.com/symfony/symfony/pull/50371.
For the rest, there's not much of a plan I'm afraid. The methods are just removed, no alternatives suggested by PHPUnit. There are some suggestions in an upstream issue to tweak with the error handler, but personally I'm not keen on that (see my comments in the PR above).
- 🇮🇹Italy mondrake 🇮🇹
PHPUnit 10.3 will introduce a mechanism to prevent its internal error handler to be active during a test's run, https://github.com/sebastianbergmann/phpunit/issues/5428, using a
#[WithoutErrorHandler]
attribute in the test method.We might leverage on that to implement an alternative error handler just for the purpose of listening to
E_(USER)*
errors, convert them to exceptions, and then have an exception expectation in the test. Or, wait for someone else (Symfony?) to propose a NIH solution.However, disabling PHPUnit's error handler means that the error events that it is capturing and dispatching will no longer be there, so we would lose that reporting, either OOB or added by a bridge for instance. Or, that the replacement error handler should take into account dealing with events dispatching, which I do not even know if it's possible.
IMHO PHPUnit have really messed everthing up big time here.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
I think that we could add something like laravel's assertThrows() to Drupal - see https://github.com/laravel/framework/blob/2d002849a16ad131110a50cbea4d64...
- 🇺🇸United States neclimdul Houston, TX
I liked that idea and needed the idea for a project outside Drupal so I wrote this.
https://gitlab.com/neclimdul/phpunit-exceptions
Its a trait that works mostly the same but has some additional functionality and the assertions are accomplished a bit different.
Let me know if this would work for Drupal or if there are changes that would help.
- 🇮🇹Italy mondrake 🇮🇹
Changed to meta.
📌 [meta] Replace calls to ::expectError*() and ::expectWarning*() Active now aims at removing
::expectError*()
method calls.📌 Upgrade PHPUnit to 10, drop Symfony PHPUnit-bridge dependency Fixed aims at finding a solution for
::expectDeprecation()
. - Status changed to Closed: duplicate
10 months ago 7:22pm 9 April 2024