@@ -125,8 +125,18 @@ variable exists and will be available in your form themes::
125
125
Use :ref: `PHPUnit data providers <testing-data-providers >` to test multiple
126
126
form conditions using the same test code.
127
127
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
+ -------------------------------------
130
140
131
141
Your form may be used as a service, as it depends on other services (e.g. the
132
142
Doctrine 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::
228
238
registered in tests. You can find other extensions from the Form component
229
239
in the ``Symfony\Component\Form\Extension `` namespace.
230
240
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
-
239
241
It is also possible to load custom form types, form type extensions or type
240
242
guessers using the :method: `Symfony\\ Component\\ Form\\ Test\\ FormIntegrationTestCase::getTypes `,
241
243
:method: `Symfony\\ Component\\ Form\\ Test\\ FormIntegrationTestCase::getTypeExtensions `
0 commit comments