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
public function testThrow()
{
$expected = new \Exception("FOO");
$this->expectException(get_class($expected));
throw $expected;
}
This doesn't:
public function testThrow()
{
$expected = new \Exception("FOO");
$this->expectException($expected);
throw $expected;
}
The method signature/PHPDoc for expectException($e) is to accept "mixed" parameter, and doesn't mind when you submit an Exception object - but it won't catch that exception object when it is thrown, even if it's that exact object that is thrown.
I'd suggest either passing instances of Exception generates an InvalidArgumentException, or instances of Exception passed in are just used to call get_class on to stringify them, or the actual instance of that exception is then expected (which I think would be less useful generally).
Either way, accepting the exception object then basically ignoring it isn't ideal...
(using PHPUnit 5.4.4)
The text was updated successfully, but these errors were encountered:
(example extends PHPUnit_Framework_TestCase)
This works fine:
This doesn't:
The method signature/PHPDoc for
expectException($e)
is to accept "mixed" parameter, and doesn't mind when you submit an Exception object - but it won't catch that exception object when it is thrown, even if it's that exact object that is thrown.I'd suggest either passing instances of
Exception
generates anInvalidArgumentException
, or instances ofException
passed in are just used to callget_class
on to stringify them, or the actual instance of that exception is then expected (which I think would be less useful generally).Either way, accepting the exception object then basically ignoring it isn't ideal...
(using PHPUnit 5.4.4)
The text was updated successfully, but these errors were encountered: