Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Deprecate MockBuilder::setMockClassName() #5444

Closed
sebastianbergmann opened this issue Jul 14, 2023 · 5 comments
Closed

Deprecate MockBuilder::setMockClassName() #5444

sebastianbergmann opened this issue Jul 14, 2023 · 5 comments
Assignees
Labels
feature/test-doubles Test Stubs and Mock Objects type/deprecation Something will be/is deprecated

Comments

@sebastianbergmann
Copy link
Owner

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

  • soft deprecation in PHPUnit 10.3 (add @deprecated annotation to the method declaration)
  • deprecation in PHPUnit 11 (using the method will trigger a deprecation)
  • removal in PHPUnit 12
@sebastianbergmann sebastianbergmann added feature/test-doubles Test Stubs and Mock Objects type/deprecation Something will be/is deprecated labels Jul 14, 2023
@sebastianbergmann sebastianbergmann added this to the PHPUnit 11.0 milestone Jul 14, 2023
@sebastianbergmann sebastianbergmann self-assigned this Jul 14, 2023
@sebastianbergmann
Copy link
Owner Author

Follows #5444.

@davidbyoung
Copy link

davidbyoung commented Aug 5, 2023

I have some unit tests where I am generating multiple mocks of the same interface with expectations set, and adding them to a registry that stores them in an associative array by their class names. I was using setMockClassName() because the multiple mocks all were assigned the same class name by PHPUnit, which was preventing them from all being stored within that registry.

Any advice for how I can accomplish what I'm trying to do with this deprecation? Thanks!

@sebastianbergmann
Copy link
Owner Author

@davidbyoung Thank you for bringing this up, I had not considered that use case.

@benhurrell
Copy link

Sorry to revive a closed issue, but given the above discussion, is setMockClassName still deprecated, and/or will it still be removed in future releases?

@sebastianbergmann
Copy link
Owner Author

It will not be deprecated in PHPUnit 10.4 and is currently scheduled for deprecation or removal.

# for free to join this conversation on GitHub. Already have an account? # 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

3 participants