-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Two common use cases I encounter with the exception expectations API is:
Exact message check instead of partial
As of now expectExceptionObject() uses expectExceptionMessage() which uses the ExceptionMessageIsOrContains() constraint. It would be nice to have the option for both to make it stricter.
Ideally, we could have expectExceptionMessage() + expectExceptionMessageIsOrContains() and make the former stricter, but that's more annoying BC wise. But either way, for expectExceptionObject() this would require an additional parameter at least...
I'm a bit conflicted because I do like to use expectExceptionObject(), but if there is not choice but to use the underlying method and use expectExceptionMessageIs() or however a new method would be called, so be it.
Exact exception instance.
Sometimes it makes more sense to check that the exception thrown is the exact one previously configured:
$exception = new FancyExceptionType();
// reset of the setup
$this->expectExceptionIdentical($exception);
// actKinda lost at what the name should be there but that's the idea.