diff --git a/docs/index.rst b/docs/index.rst index 1355a89c6..a4befee73 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -181,6 +181,21 @@ This command will generate a ``PostFactory`` class that looks like this: Using ``make:factory --test`` will generate the factory in ``tests/Factory``. +.. tip:: + + When using ``--test`` flag, we're still dealing with ``dev`` environment. And because we want the container to know about our factories, + we need to declare them as services even if they are in the ``tests`` directory. To do that, add the following to your configuration: + + .. code-block:: yaml + + # config/packages/zenstruck_foundry.yaml + when@dev: + services: + App\Tests\Factory\: + resource: '%kernel.project_dir%/tests/Factory/' + autowire: true + autoconfigure: true + .. tip:: You can globally configure which namespace the factories will be generated in: