-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat: "in memory" behavior #590
base: 2.x
Are you sure you want to change the base?
Conversation
3e88d34
to
f7be7ac
Compare
f6684d2
to
7914ee1
Compare
23b2122
to
51dac5b
Compare
56a501b
to
558fc5f
Compare
90502f7
to
7608b78
Compare
7608b78
to
191bdf4
Compare
6e979f6
to
6135e03
Compare
6135e03
to
5cb5d9a
Compare
* @author Nicolas PHILIPPE <[email protected]> | ||
*/ | ||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)] | ||
final class AsInMemoryTest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
This is brilliant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, let's roll after some docs?
yes! I'll add some doc soon. I also think I will release Foundry 2.4 before, A second PR around "in memory" will land before: I want to provide a |
This PR introduces "in-memory" behavior
fixes #533
It makes integration testing with "in memory" repositories very easy!
Here is the proposal:
Given some kind of DDD or hexagonal architecture, repositories in domain are usually interfaces, which main implementation is a Doctrine one. "in memory" version of these repositories will exist and would be injected in the container in test environment.
This PR exposes a new interface
Zenstruck\Foundry\InMemory\InMemoryRepository
, e.g.:It also exposes a new attribute
#[AsInMemoryTest]
, which will disable persistence of the factories, and register an "after instantiate" hook, which will store the objects in their respective "in memory" repositories:A
GenericInMemoryRepository
is also added for convenience, when the given in memory repository is missing.