@@ -50,8 +50,13 @@ public function setReferenceCopy($reference)
50
50
}
51
51
}
52
52
53
- class FormTypeTest extends TypeTestCase
53
+ class FormTypeTest extends BaseTypeTest
54
54
{
55
+ public function testCreateFormInstances ()
56
+ {
57
+ $ this ->assertInstanceOf ('Symfony\Component\Form\Form ' , $ this ->factory ->create ('form ' ));
58
+ }
59
+
55
60
public function testPassRequiredAsOption ()
56
61
{
57
62
$ form = $ this ->factory ->create ('form ' , null , array ('required ' => false ));
@@ -63,13 +68,6 @@ public function testPassRequiredAsOption()
63
68
$ this ->assertTrue ($ form ->isRequired ());
64
69
}
65
70
66
- public function testPassDisabledAsOption ()
67
- {
68
- $ form = $ this ->factory ->create ('form ' , null , array ('disabled ' => true ));
69
-
70
- $ this ->assertTrue ($ form ->isDisabled ());
71
- }
72
-
73
71
public function testBoundDataIsTrimmedBeforeTransforming ()
74
72
{
75
73
$ form = $ this ->factory ->createBuilder ('form ' )
@@ -102,49 +100,6 @@ public function testBoundDataIsNotTrimmedBeforeTransformingIfNoTrimming()
102
100
$ this ->assertEquals ('reverse[ a ] ' , $ form ->getData ());
103
101
}
104
102
105
- public function testPassIdAndNameToView ()
106
- {
107
- $ form = $ this ->factory ->createNamed ('name ' , 'form ' );
108
- $ view = $ form ->createView ();
109
-
110
- $ this ->assertEquals ('name ' , $ view ->vars ['id ' ]);
111
- $ this ->assertEquals ('name ' , $ view ->vars ['name ' ]);
112
- $ this ->assertEquals ('name ' , $ view ->vars ['full_name ' ]);
113
- }
114
-
115
- public function testStripLeadingUnderscoresAndDigitsFromId ()
116
- {
117
- $ form = $ this ->factory ->createNamed ('_09name ' , 'form ' );
118
- $ view = $ form ->createView ();
119
-
120
- $ this ->assertEquals ('name ' , $ view ->vars ['id ' ]);
121
- $ this ->assertEquals ('_09name ' , $ view ->vars ['name ' ]);
122
- $ this ->assertEquals ('_09name ' , $ view ->vars ['full_name ' ]);
123
- }
124
-
125
- public function testPassIdAndNameToViewWithParent ()
126
- {
127
- $ parent = $ this ->factory ->createNamed ('parent ' , 'form ' );
128
- $ parent ->add ($ this ->factory ->createNamed ('child ' , 'form ' ));
129
- $ view = $ parent ->createView ();
130
-
131
- $ this ->assertEquals ('parent_child ' , $ view ['child ' ]->vars ['id ' ]);
132
- $ this ->assertEquals ('child ' , $ view ['child ' ]->vars ['name ' ]);
133
- $ this ->assertEquals ('parent[child] ' , $ view ['child ' ]->vars ['full_name ' ]);
134
- }
135
-
136
- public function testPassIdAndNameToViewWithGrandParent ()
137
- {
138
- $ parent = $ this ->factory ->createNamed ('parent ' , 'form ' );
139
- $ parent ->add ($ this ->factory ->createNamed ('child ' , 'form ' ));
140
- $ parent ['child ' ]->add ($ this ->factory ->createNamed ('grand_child ' , 'form ' ));
141
- $ view = $ parent ->createView ();
142
-
143
- $ this ->assertEquals ('parent_child_grand_child ' , $ view ['child ' ]['grand_child ' ]->vars ['id ' ]);
144
- $ this ->assertEquals ('grand_child ' , $ view ['child ' ]['grand_child ' ]->vars ['name ' ]);
145
- $ this ->assertEquals ('parent[child][grand_child] ' , $ view ['child ' ]['grand_child ' ]->vars ['full_name ' ]);
146
- }
147
-
148
103
public function testNonReadOnlyFormWithReadOnlyParentBeingReadOnly ()
149
104
{
150
105
$ parent = $ this ->factory ->createNamed ('parent ' , 'form ' , null , array ('read_only ' => true ));
@@ -180,57 +135,6 @@ public function testPassMaxLengthToView()
180
135
$ this ->assertSame (10 , $ view ->vars ['max_length ' ]);
181
136
}
182
137
183
- public function testPassTranslationDomainToView ()
184
- {
185
- $ form = $ this ->factory ->create ('form ' , null , array ('translation_domain ' => 'test ' ));
186
- $ view = $ form ->createView ();
187
-
188
- $ this ->assertSame ('test ' , $ view ->vars ['translation_domain ' ]);
189
- }
190
-
191
- public function testNonTranslationDomainFormWithTranslationDomainParentBeingTranslationDomain ()
192
- {
193
- $ parent = $ this ->factory ->createNamed ('parent ' , 'form ' , null , array ('translation_domain ' => 'test ' ));
194
- $ child = $ this ->factory ->createNamed ('child ' , 'form ' );
195
- $ view = $ parent ->add ($ child )->createView ();
196
-
197
- $ this ->assertEquals ('test ' , $ view ['child ' ]->vars ['translation_domain ' ]);
198
- }
199
-
200
- public function testTranslationDomainFormWithNonTranslationDomainParentBeingTranslationDomain ()
201
- {
202
- $ parent = $ this ->factory ->createNamed ('parent ' , 'form ' );
203
- $ child = $ this ->factory ->createNamed ('child ' , 'form ' , null , array ('translation_domain ' => 'test ' ));
204
- $ view = $ parent ->add ($ child )->createView ();
205
-
206
- $ this ->assertEquals ('test ' , $ view ['child ' ]->vars ['translation_domain ' ]);
207
- }
208
-
209
- public function testNonTranslationDomainFormWithNonTranslationDomainParentBeingTranslationDomainDefault ()
210
- {
211
- $ parent = $ this ->factory ->createNamed ('parent ' , 'form ' );
212
- $ child = $ this ->factory ->createNamed ('child ' , 'form ' );
213
- $ view = $ parent ->add ($ child )->createView ();
214
-
215
- $ this ->assertEquals ('messages ' , $ view ['child ' ]->vars ['translation_domain ' ]);
216
- }
217
-
218
- public function testPassLabelToView ()
219
- {
220
- $ form = $ this ->factory ->createNamed ('__test___field ' , 'form ' , null , array ('label ' => 'My label ' ));
221
- $ view = $ form ->createView ();
222
-
223
- $ this ->assertSame ('My label ' , $ view ->vars ['label ' ]);
224
- }
225
-
226
- public function testDefaultTranslationDomain ()
227
- {
228
- $ form = $ this ->factory ->create ('form ' );
229
- $ view = $ form ->createView ();
230
-
231
- $ this ->assertSame ('messages ' , $ view ->vars ['translation_domain ' ]);
232
- }
233
-
234
138
public function testBindWithEmptyDataCreatesObjectIfClassAvailable ()
235
139
{
236
140
$ form = $ this ->factory ->create ('form ' , null , array (
@@ -404,6 +308,7 @@ public function testNameCanBeEmptyString()
404
308
405
309
$ this ->assertEquals ('' , $ form ->getName ());
406
310
}
311
+
407
312
public function testSubformDoesntCallSetters ()
408
313
{
409
314
$ author = new FormTest_AuthorWithoutRefSetter (new Author ());
@@ -523,14 +428,6 @@ function ($value) use ($ref2) { // reverseTransform
523
428
$ this ->assertSame ($ ref2 , $ author ['referenceCopy ' ]);
524
429
}
525
430
526
- public function testPassMultipartFalseToView ()
527
- {
528
- $ form = $ this ->factory ->create ('form ' );
529
- $ view = $ form ->createView ();
530
-
531
- $ this ->assertFalse ($ view ->vars ['multipart ' ]);
532
- }
533
-
534
431
public function testPassMultipartTrueIfAnyChildIsMultipartToView ()
535
432
{
536
433
$ form = $ this ->factory ->create ('form ' );
@@ -661,4 +558,9 @@ public function testPassZeroLabelToView()
661
558
662
559
$ this ->assertSame ('0 ' , $ view ->vars ['label ' ]);
663
560
}
561
+
562
+ protected function getTestedType ()
563
+ {
564
+ return 'form ' ;
565
+ }
664
566
}
0 commit comments