New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asserts: Add expectThrowable() method #5213
Conversation
With this method you can not only test Exceptions, like with expectException, but also Errors. Signed-off-by: Bernd Stellwag <burned@zerties.org>
Signed-off-by: Bernd Stellwag <burned@zerties.org>
Signed-off-by: Bernd Stellwag <burned@zerties.org>
Signed-off-by: Bernd Stellwag <burned@zerties.org>
…hrowable instead Signed-off-by: Bernd Stellwag <burned@zerties.org>
Signed-off-by: Bernd Stellwag <burned@zerties.org>
I think it's ok how it is. I got used to it )
Thanks. Everything looks fine, I just didn't have enough time to review it before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes required
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\AssertionFailedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, could you update the code to not use this annotation?
Because of sebastianbergmann/phpunit#3332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sure, thanks for pointing that out, didn't know that! :)
Fixed in f8a2b52
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\AssertionFailedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use annotations sebastianbergmann/phpunit#3332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f8a2b52
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\AssertionFailedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use annotations sebastianbergmann/phpunit#3332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f8a2b52
|
||
/** | ||
* @expectedException PHPUnit\Framework\AssertionFailedError | ||
* @expectedExceptionMessageRegExp /RuntimeException/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use annotations sebastianbergmann/phpunit#3332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f8a2b52
Alright, so should I then just remove those lines?
Thanks for reviewing :) |
Thanks. Let's do that! |
I thought it would be quite useful to be also able to test for Errors and (possibly in future) other Throwables, too instead of just Exceptions.
So this pull request would add a new method
expectThrowable()
and refactorexpectException()
to just call this method. I also suggest markingexpectException()
as deprecated since I think the old method could be removed some time later (maybe with a new major release or such?). I also added some tests and updated the documentation. Please tell me what you think about this and if there are any additional steps required that I didn't know of.