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

Deprecate TestCase::createTestProxy() #5240

Closed
sebastianbergmann opened this issue Feb 23, 2023 · 1 comment
Closed

Deprecate TestCase::createTestProxy() #5240

sebastianbergmann opened this issue Feb 23, 2023 · 1 comment
Assignees
Labels
feature/test-doubles Test Stubs and Mock Objects type/deprecation Something will be/is deprecated
Milestone

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Feb 23, 2023

The createTestProxy() method can be used to create a so-called test proxy: an object where all methods of the original class are replaced with an implementation that can be configured to expect an invocation but otherwise retains its original behaviour. They are "documented" here.

While the idea for test proxies was appealing, I have never seen this feature used "in the wild" to a degree that would warrant keeping it around.

To reduce complexity inside PHPUnit's test double functionality, TestCase::createTestProxy() will be deprecated and then removed:

  • soft deprecation in PHPUnit 10.1 (add @deprecated annotation to the method declaration)
  • deprecation in PHPUnit 11 (using the method will trigger a deprecation)
  • removal in PHPUnit 12
@odahcam
Copy link

odahcam commented Jul 31, 2024

I was implementing this method right now. How am I supposed to assert things inside a method that has a return type void if I can't do a proxy in one of its dependencies to assert the values?

Edit: I used the $this->createStub to create a class and did assertions inside the ::method::willReturnCallback. Is this horrible? Is there a better way to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-doubles Test Stubs and Mock Objects type/deprecation Something will be/is deprecated
Projects
None yet
Development

No branches or pull requests

2 participants