@@ -36,8 +36,8 @@ The Basics
36
36
37
37
The simplest ``TypeTestCase `` implementation looks like the following::
38
38
39
- // src /AppBundle/Tests /Form/Type/TestedTypeTest.php
40
- namespace AppBundle\ Tests\Form\Type;
39
+ // tests /AppBundle/Form/Type/TestedTypeTest.php
40
+ namespace Tests\AppBundle \Form\Type;
41
41
42
42
use AppBundle\Form\Type\TestedType;
43
43
use AppBundle\Model\TestObject;
@@ -117,15 +117,18 @@ might look like this::
117
117
118
118
// src/AppBundle/Form/Type/TestedType.php
119
119
120
- // ... the buildForm method
121
- $builder->add('app_test_child_type');
120
+ // ...
121
+ public function buildForm(FormBuilderInterface $builder, array $options)
122
+ {
123
+ $builder->add('app_test_child_type');
124
+ }
122
125
123
126
To create your form correctly, you need to make the type available to the
124
127
form factory in your test. The easiest way is to register it manually
125
128
before creating the parent form using the ``PreloadedExtension `` class::
126
129
127
- // src /AppBundle/Tests /Form/Type/TestedTypeTests.php
128
- namespace AppBundle\ Tests\Form\Type;
130
+ // tests /AppBundle/Form/Type/TestedTypeTests.php
131
+ namespace Tests\AppBundle \Form\Type;
129
132
130
133
use AppBundle\Form\Type\TestedType;
131
134
use AppBundle\Model\TestObject;
@@ -158,7 +161,7 @@ before creating the parent form using the ``PreloadedExtension`` class::
158
161
be getting errors that are not related to the form you are currently
159
162
testing but to its children.
160
163
161
- Adding custom Extensions
164
+ Adding Custom Extensions
162
165
------------------------
163
166
164
167
It often happens that you use some options that are added by
@@ -168,8 +171,8 @@ The ``TypeTestCase`` loads only the core form extension so an "Invalid option"
168
171
exception will be raised if you try to use it for testing a class that depends
169
172
on other extensions. You need to add those extensions to the factory object::
170
173
171
- // src /AppBundle/Tests /Form/Type/TestedTypeTests.php
172
- namespace AppBundle\ Tests\Form\Type;
174
+ // tests /AppBundle/Form/Type/TestedTypeTests.php
175
+ namespace Tests\AppBundle \Form\Type;
173
176
174
177
use AppBundle\Form\Type\TestedType;
175
178
use AppBundle\Model\TestObject;
@@ -217,16 +220,15 @@ Testing against different Sets of Data
217
220
If you are not familiar yet with PHPUnit's `data providers `_, this might be
218
221
a good opportunity to use them::
219
222
220
- // src /AppBundle/Tests /Form/Type/TestedTypeTests.php
221
- namespace AppBundle\ Tests\Form\Type;
223
+ // tests /AppBundle/Form/Type/TestedTypeTests.php
224
+ namespace Tests\AppBundle \Form\Type;
222
225
223
226
use AppBundle\Form\Type\TestedType;
224
227
use AppBundle\Model\TestObject;
225
228
use Symfony\Component\Form\Test\TypeTestCase;
226
229
227
230
class TestedTypeTest extends TypeTestCase
228
231
{
229
-
230
232
/**
231
233
* @dataProvider getValidTestData
232
234
*/
0 commit comments