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

I think we need a way to reset/flush the Container state (specifically when running in a test environment) #64

Open
defunctl opened this issue Nov 11, 2024 · 0 comments

Comments

@defunctl
Copy link
Contributor

For example, something like Laravel's flush() method.

Through tearDown(), this flushes the container so each test starts with a fresh set of container definitions and aren't reused in between tests. This has the benefit of resetting all mocked instances in the container.

Right now with di52, we have to actively think about how singleton definitions will affect other tests, for example if a definition is defined to use a singleton, and an early test registers a Mock in the container, then other tests down the road will use that same mock instance instead when getting the instance out of the container.

Note: I'm not 100% sure if this a problem with slic/codeception potentially running all the tests using the same process.

The only way to manually do this right now as far as I know is using offsetUnset(), and you need to know all the IDs ahead of time.

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

No branches or pull requests

1 participant