Skip to content
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

Add TestCase::registerFailureInterface() to register interface that marks exceptions to be treated as failures, not errors #5201

Closed
sebastianbergmann opened this issue Feb 14, 2023 · 3 comments
Assignees
Labels
feature/test-runner CLI test runner type/enhancement A new idea that should be implemented
Milestone

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Feb 14, 2023

Motivated by phpspec/prophecy-phpunit#45 (comment)

@sebastianbergmann sebastianbergmann added type/enhancement A new idea that should be implemented feature/test-runner CLI test runner labels Feb 14, 2023
@sebastianbergmann sebastianbergmann added this to the PHPUnit 10.1 milestone Feb 14, 2023
@sebastianbergmann sebastianbergmann self-assigned this Feb 14, 2023
@sebastianbergmann sebastianbergmann changed the title Add marker interface to be implemented by exceptions that should be treated as failure, not as an error Add TestCase::registerFailureInterface() to register interface that marks exceptions to be treated as failures, not errors Feb 14, 2023
@sebastianbergmann
Copy link
Owner Author

@stof @Jean85 Any feedback on this prior to the release of PHPUnit 10.1 would be much appreciated.

Jean85 added a commit to Jean85/prophecy-phpunit that referenced this issue Feb 19, 2023
@Jean85
Copy link
Contributor

Jean85 commented Feb 20, 2023

I've integrated it into phpspec/prophecy-phpunit#45, thanks!
As of now though, we're still blocked by phpspec/prophecy#585, so it's not tested under CI yet (but locally it seems to work).

As for comments, only two come to mind for now:

  • since you're using instanceof, it works with classes too, not only interfaces; which is good! But maybe it warrants a rename?
  • I would record FQCNs as keys, not values, to avoid duplications (multiple calls would be idempotent)

@sebastianbergmann
Copy link
Owner Author

since you're using instanceof, it works with classes too, not only interfaces; which is good! But maybe it warrants a rename?

Makes sense, implemented in 28766f5.

I would record FQCNs as keys, not values, to avoid duplications (multiple calls would be idempotent)

Makes sense, implemented in a249d88.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

2 participants