Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81eacf5

Browse files
authored
docs: add a note about using make:factory --test (#1000)
1 parent deb4d0e commit 81eacf5

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

docs/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ This command will generate a ``PostFactory`` class that looks like this:
181181

182182
Using ``make:factory --test`` will generate the factory in ``tests/Factory``.
183183

184+
.. tip::
185+
186+
When using ``--test`` flag, we're still dealing with ``dev`` environment. And because we want the container to know about our factories,
187+
we need to declare them as services even if they are in the ``tests`` directory. To do that, add the following to your configuration:
188+
189+
.. code-block:: yaml
190+
191+
# config/packages/zenstruck_foundry.yaml
192+
when@dev:
193+
services:
194+
App\Tests\Factory\:
195+
resource: '%kernel.project_dir%/tests/Factory/'
196+
autowire: true
197+
autoconfigure: true
198+
184199
.. tip::
185200

186201
You can globally configure which namespace the factories will be generated in:

0 commit comments

Comments
 (0)