-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Question/Problem: Using Foundry in Doctrine Fixtures with service injection #101
Comments
Hello, I think perhaps your factories are not being autowired/autoconfigured. Can you find the service with |
Closing as stale. If you're still having issues, let me know and I'll reopen. |
I've encountered this issue:
Fix:
|
https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#stories-as-services describes that the tag is needed (below the example). Could probably make that pop a bit more with it as a note. |
@kbond
Or in tests, like:
I always getting an error: |
@Perf where is your userfacrory located? It needs to be autoconfigured/autowired. |
it's located under |
Hmm, ok, can you find the factory with debug:container? |
What does your I tried a branch new |
nope, absolutely nothing found
|
Hi @Perf with this don't you have any other config file? maybe for test environment? |
Hi @nikophil
I have 2 other configs, but they are empty
no configs for test env |
maybe your glob patterns do not work as expected? (although they look good to me) Foundry does not make funky stuff with dependency injection, beside of tagging classes which extend |
hey @nikophil |
I'm curious to know the origin of the problem, when you'll find it out! |
I updated excludes to the following and now
Now excludes are more explicit ) |
yes but, which one was excluding the path |
|
ok, thanks, good to know... this is... very strange! 😅 |
I want to use
UserPasswordEncoderInterface
in myUserFactory
to set the encoded password after instantiate. When I try to create my Factory ($userAdmin = UserFactory::new();
), I get:but Flex registered the Bundle:
Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'test' => true],
It looks like Foundry has booted, but the injected
$factories
in\Zenstruck\Foundry\ModelFactoryManager
are empty.The text was updated successfully, but these errors were encountered: