@@ -125,8 +125,18 @@ variable exists and will be available in your form themes::
125125 Use :ref: `PHPUnit data providers <testing-data-providers >` to test multiple
126126 form conditions using the same test code.
127127
128- Testings Types from the Service Container
129- -----------------------------------------
128+ .. caution ::
129+
130+ When your type relies on the ``EntityType ``, you should register the
131+ :class: `Symfony\\ Bridge\\ Doctrine\\ Form\\ DoctrineOrmExtension `, which will
132+ need to mock the ``ManagerRegistry ``.
133+
134+ However, If you cannot use a mock to write your test, you should extend
135+ the ``KernelTestCase `` instead and use the ``form.factory `` service to
136+ create the form.
137+
138+ Testings Types Registered as Services
139+ -------------------------------------
130140
131141Your form may be used as a service, as it depends on other services (e.g. the
132142Doctrine entity manager). In these cases, using the above code won't work, as
@@ -228,14 +238,6 @@ allows you to return a list of extensions to register::
228238 registered in tests. You can find other extensions from the Form component
229239 in the ``Symfony\Component\Form\Extension `` namespace.
230240
231- .. caution ::
232-
233- When your type relies on the ``EntityType ``, you should register the
234- :class: `Symfony\\ Bridge\\ Doctrine\\ Form\\ DoctrineOrmExtension `, which will
235- need to mock the ``ManagerRegistry ``. If you cannot use a mock to write
236- your test, you should extend the ``KernelTestCase `` instead and use the
237- form factory as a service by fetching it from the container.
238-
239241It is also possible to load custom form types, form type extensions or type
240242guessers using the :method: `Symfony\\ Component\\ Form\\ Test\\ FormIntegrationTestCase::getTypes `,
241243:method: `Symfony\\ Component\\ Form\\ Test\\ FormIntegrationTestCase::getTypeExtensions `
0 commit comments