You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you specify the exception message in a throw() assertion, the type check is currently bypassed.
Code to reproduce:
<?phpdescribe('Bug with throw()', function () {
it('should assert type', function () {
$actual = function () {
$throws = function () { thrownewException(); };
expect($throws)->to->throw('RuntimeException');
};
expect($actual)->to->throw('Peridot\Leo\Responder\Exception\AssertionException');
});
it('should assert type even when message is specified', function () {
$actual = function () {
$throws = function () { thrownewException('foobar'); };
expect($throws)->to->throw('RuntimeException', 'foobar');
};
expect($actual)->to->throw('Peridot\Leo\Responder\Exception\AssertionException');
});
});
The first test passes because Exception is not a RuntimeException. The second test fails because the message argument bypasses the type check.
This section of the code seems to be the offender, in ExceptionMatcher::doMatch():
$message = $e->getMessage();
if ($this->expectedMessage) {
$this->setMessage($message);
return$this->expectedMessage == $message;
}
if (!$e instanceof $this->expected) {
returnfalse;
}
I tried fixing it myself but couldn't figure out how to get it to produce the correct error message in all cases.
The text was updated successfully, but these errors were encountered:
When you specify the exception message in a
throw()
assertion, the type check is currently bypassed.Code to reproduce:
The first test passes because
Exception
is not aRuntimeException
. The second test fails because the message argument bypasses the type check.This section of the code seems to be the offender, in
ExceptionMatcher::doMatch()
:I tried fixing it myself but couldn't figure out how to get it to produce the correct error message in all cases.
The text was updated successfully, but these errors were encountered: