Missing expectation: expectWarning()?
I see a nice yellow WARN:
But I'm explicitly expecting a warning here. My test covers this through error_get_last as a workaround; however, it would be nice to simply:
it('emits a warning', function() {
trigger_error('warn', E_USER_WARNING);
})->expectWarningMessage('warn');
Similar to how exceptions can be checked.
I'd prefer to throw an exception in my library; however, that would be disastrous since nothing would break unless the library is used in a particular way. So, a warning is emitted so that the developer can either ignore it or choose to throw an exception if it effects them.
This would be helpful to avoid warnings in our Pest output, as we have some tests which involve intentionally passing bad data to PHP's unserialize, which emits a warning. Currently there is no way to tell Pest that we expect this warning, and there is no way to tell PHP to stop emitting this warning.
I'd like to enable some of the stricter flags, such as "fail test on (unexpected) warning", but currently we must allow warnings to allow tests like these to function.
you can make a pull request or just use the methods from phpujnit: https://github.com/sebastianbergmann/phpunit/issues/3775.