-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Refactor #1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- make() - makeMany() - create() - createMany()
- persist() -> create() - persistMany() -> createMany()
- by default, use symfony/property-access to set values and disallow extra properties - attribute keys can be prefixed with "optional:" to ignore - attribute keys can be prefixed with "force:" to "force set" their value to properties directly - add option to disable constructor - add option to always allow extra attributes - add option to always "force set" attributes
- remove self return type, add return static to docblock - ensure instance of current factory is returned
…rnative: - $factory->withoutPersisting()->create()->object() - array_map(fn($p) => $p->object(), $factory->withoutPersisting()->createMany())
- make Manager constructor arguments required - remove Manager::boot() - make Manager/StoryManager services - call Factory::boot() in ZenstruckFoundryBundle::boot()
- add test to ensure stories as services are loaded correctly
- proxies created in global state would have a different "Manager" than the one used in your tests causing the om to think these were not persisted. Always grabbing the current manager from Factory::manager() solves this. - also removed injecting into RepositoryProxy to be consistent.
- using without bundle must be explicitly configured
Makes the method a bit clearer.
- rename withAutoRefresh() to enableAutoRefresh() - rename withoutAutoRefresh() to disableAutoRefresh() - add withoutAutoRefresh(callable) to disable before executing callback and re-enable after - withoutAutoRefresh's closure takes the Proxy by default, but if its type-hint is the wrapped object, it is passed
- also split ModelFactory::randomSet() into randomSet/randomRange
add --test option to generate in tests/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ModelFactory::make()/makeMany()/create()/createMany()
Factory::persist()
tocreate()
Factory::persistMany()
tocreateMany()
Instantiator
(Refactor instantiator #2)([POC] add integration with Doctrine DataFixtures #3)([POC] Refactor static state #8)ModelFactory::initialize()
([bug] refactor ModelFactory::initialize() #4)RepositoryProxy::randomSet()
andModelFactory::randomSet()
into 2 distinct methods: Random helpers #5 (comment) (randomSet()
andrandomRange()
?) ([minor] Split RepositoryProxy::randomSet() into randomSet/randomRange #10)Proxy::autoRefreshByDefault()
Proxy
state (Unpersisted proxy #7)Factory::instantiate()
- addFactory::withoutPersisting()
($factory->withoutPersisting()->create()
as the replacement) (Unpersisted proxy #7)src/
instead oftests/
(--test
flag?) ([minor] Default makers to generate in src/ #9)Factory::instantiator()
toFactory::instantiateWith()
([minor] rename Factory::instantiate() to instantiateWith() #11)Proxy::withoutAutoRefresh(callable)
,Proxy::enableAutoRefresh()
,Proxy::disableAutoRefresh()
([minor] refactor Proxy auto-refresh methods #12)HaveFactory::createMany()
return aProxyCollection
(ArrayAccess
) to make possible future helpers w/o bc break