-
-
Notifications
You must be signed in to change notification settings - Fork 107
docs: add a note about using make:factory --test
#1000
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
Conversation
… registered in the service container when using `make:factory --test`
8635d76 to
653cd13
Compare
nikophil
left a comment
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 very relevant!
I don't know if you dug into some old PRs, but this is very related to this comment. Thus, I think this fixes #786
I'm even wondering if we should not add this to the Foundry's recipe.
Actually, I think we should do this in config/packages/zenstruck_foundry.yaml, but I'm not 100% convinced, WDYT?
@kbond any thoughts? We talked about this few months ago
docs/index.rst
Outdated
| Using ``make:factory --test`` will generate the factory in ``tests/Factory``. | ||
|
|
||
| If your entity has some properties with Doctrine relationships, the factories for the related entities must be registered | ||
| in the service container so that the maker command can find them. To do that, add the following to your ``services.yaml``. |
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.
I don't think the problem is about "entities [which] has some properties with Doctrine relationships"
I think the problem this resolves is something like:
When using
--testflag, we're still dealing withdevenvironment. And because we want the container to know about our factories, we need to declare them as services even if they are in thetestdirectory. To do that, add the following to yourservices.yaml
don't hesitate to rephrase, this problem is hard to explain in a meaningful way
|
Oh, I thought I'd looked into the old issue/PR, but I overlooked it. You're right. I also think that registering files under Essentially, I think the solution outlined in your comment below would be preferable. In my opinion, ideally, the The basic premise is that the Therefore, the way In my opinion, simply hard-coding the list of folders in |
not sure to agree, loading classes based on their path brings some boilerplate code which I'd prefer to not add here (is this psr4 ? psr0 ? etc...) I think the best solution (well... the least worth solution 😅) is to document this the way you've already done it. Please could you adapt the PR with the following:
thanks! (hey this PR is the 1000th! 🎉) |
|
@nikophil I've updated this PR and also submitted a PR to recipe. Note that since we assume that the configuration will be written in (Congrats on 1,000 (PR|Issue)s 🎊) |
d7ba72d to
f4c759a
Compare
|
Can't we use |
|
@nikophil Surely! (It's |
|
thanks @ttskch |
Closes #786