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

[8.x] Forget and clear a mocked/spied instance of an object in the container #39713

Merged
merged 4 commits into from
Nov 22, 2021

Conversation

khalilst
Copy link
Contributor

@khalilst khalilst commented Nov 20, 2021

This PR was inspired by Jest's mockRestore() method.
It introduces new forgetMock() method which uses forgetInstance() method internally and has a better DX.

The use-case:
Consider we have multiple test methods using a mocked/spied instance of an object which is prepared in the setUp() method.
If in that class some tests want to run tests without mock, they can call the forgetMock() method.

@driesvints
Copy link
Member

Can't we just also call this forgetInstance to keep it the same and generic?

@khalilst
Copy link
Contributor Author

Just hard to guess without knowing what is going on behind the scene.

@taylorotwell taylorotwell merged commit e1cae7e into laravel:8.x Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants