@@ -25,14 +25,14 @@ abstract class BaseTypeTest extends TypeTestCase
25
25
26
26
public function testPassDisabledAsOption ()
27
27
{
28
- $ form = $ this ->factory ->create ($ this ->getTestedType (), null , ['disabled ' => true ]);
28
+ $ form = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), ['disabled ' => true ]) );
29
29
30
30
$ this ->assertTrue ($ form ->isDisabled ());
31
31
}
32
32
33
33
public function testPassIdAndNameToView ()
34
34
{
35
- $ view = $ this ->factory ->createNamed ('name ' , $ this ->getTestedType ())
35
+ $ view = $ this ->factory ->createNamed ('name ' , $ this ->getTestedType (), null , $ this -> getTestOptions () )
36
36
->createView ();
37
37
38
38
$ this ->assertEquals ('name ' , $ view ->vars ['id ' ]);
@@ -42,7 +42,7 @@ public function testPassIdAndNameToView()
42
42
43
43
public function testStripLeadingUnderscoresAndDigitsFromId ()
44
44
{
45
- $ view = $ this ->factory ->createNamed ('_09name ' , $ this ->getTestedType ())
45
+ $ view = $ this ->factory ->createNamed ('_09name ' , $ this ->getTestedType (), null , $ this -> getTestOptions () )
46
46
->createView ();
47
47
48
48
$ this ->assertEquals ('name ' , $ view ->vars ['id ' ]);
@@ -53,7 +53,7 @@ public function testStripLeadingUnderscoresAndDigitsFromId()
53
53
public function testPassIdAndNameToViewWithParent ()
54
54
{
55
55
$ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
56
- ->add ('child ' , $ this ->getTestedType ())
56
+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
57
57
->getForm ()
58
58
->createView ();
59
59
@@ -66,7 +66,7 @@ public function testPassIdAndNameToViewWithGrandParent()
66
66
{
67
67
$ builder = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
68
68
->add ('child ' , FormTypeTest::TESTED_TYPE );
69
- $ builder ->get ('child ' )->add ('grand_child ' , $ this ->getTestedType ());
69
+ $ builder ->get ('child ' )->add ('grand_child ' , $ this ->getTestedType (), $ this -> getTestOptions () );
70
70
$ view = $ builder ->getForm ()->createView ();
71
71
72
72
$ this ->assertEquals ('parent_child_grand_child ' , $ view ['child ' ]['grand_child ' ]->vars ['id ' ]);
@@ -76,9 +76,9 @@ public function testPassIdAndNameToViewWithGrandParent()
76
76
77
77
public function testPassTranslationDomainToView ()
78
78
{
79
- $ view = $ this ->factory ->create ($ this ->getTestedType (), null , [
79
+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), [
80
80
'translation_domain ' => 'domain ' ,
81
- ])
81
+ ]))
82
82
->createView ();
83
83
84
84
$ this ->assertSame ('domain ' , $ view ->vars ['translation_domain ' ]);
@@ -90,7 +90,7 @@ public function testInheritTranslationDomainFromParent()
90
90
->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
91
91
'translation_domain ' => 'domain ' ,
92
92
])
93
- ->add ('child ' , $ this ->getTestedType ())
93
+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
94
94
->getForm ()
95
95
->createView ();
96
96
@@ -103,9 +103,9 @@ public function testPreferOwnTranslationDomain()
103
103
->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
104
104
'translation_domain ' => 'parent_domain ' ,
105
105
])
106
- ->add ('child ' , $ this ->getTestedType (), [
106
+ ->add ('child ' , $ this ->getTestedType (), array_merge ( $ this -> getTestOptions (), [
107
107
'translation_domain ' => 'domain ' ,
108
- ])
108
+ ]))
109
109
->getForm ()
110
110
->createView ();
111
111
@@ -115,7 +115,7 @@ public function testPreferOwnTranslationDomain()
115
115
public function testDefaultTranslationDomain ()
116
116
{
117
117
$ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
118
- ->add ('child ' , $ this ->getTestedType ())
118
+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
119
119
->getForm ()
10000
120
120
->createView ();
121
121
@@ -126,9 +126,9 @@ public function testPassLabelTranslationParametersToView()
126
126
{
127
127
$ this ->requiresFeatureSet (403 );
128
128
129
- $ view = $ this ->factory ->create ($ this ->getTestedType (), null , [
129
+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), [
130
130
'label_translation_parameters ' => ['%param% ' => 'value ' ],
131
- ])
131
+ ]))
132
132
->createView ();
133
133
134
134
$ this ->assertSame (['%param% ' => 'value ' ], $ view ->vars ['label_translation_parameters ' ]);
@@ -138,9 +138,9 @@ public function testPassAttrTranslationParametersToView()
138
138
{
139
139
$ this ->requiresFeatureSet (403 );
140
140
141
- $ view = $ this ->factory ->create ($ this ->getTestedType (), null , [
141
+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), [
142
142
'attr_translation_parameters ' => ['%param% ' => 'value ' ],
143
- ])
143
+ ]))
144
144
->createView ();
145
145
146
146
$ this ->assertSame (['%param% ' => 'value ' ], $ view ->vars ['attr_translation_parameters ' ]);
@@ -154,7 +154,7 @@ public function testInheritLabelTranslationParametersFromParent()
154
154
->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
155
155
'label_translation_parameters ' => ['%param% ' => 'value ' ],
156
156
])
157
- ->add ('child ' , $ this ->getTestedType ())
157
+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
158
158
->getForm ()
159
159
->createView ();
160
160
@@ -169,7 +169,7 @@ public function testInheritAttrTranslationParametersFromParent()
169
169
->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
170
170
'attr_translation_parameters ' => ['%param% ' => 'value ' ],
171
171
])
172
- ->add ('child ' , $ this ->getTestedType ())
172
+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
173
173
->getForm ()
174
174
->createView ();
175
175
@@ -184,9 +184,9 @@ public function testPreferOwnLabelTranslationParameters()
184
184
->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
185
185
'label_translation_parameters ' => ['%parent_param% ' => 'parent_value ' , '%override_param% ' => 'parent_override_value ' ],
186
186
])
187
- ->add ('child ' , $ this ->getTestedType (), [
187
+ ->add ('child ' , $ this ->getTestedType (), array_merge ( $ this -> getTestOptions (), [
188
188
'label_translation_parameters ' => ['%override_param% ' => 'child_value ' ],
189
- ])
189
+ ]))
190
190
->getForm ()
191
191
->createView ();
192
192
@@ -201,9 +201,9 @@ public function testPreferOwnAttrTranslationParameters()
201
201
->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
202
202
'attr_translation_parameters ' => ['%parent_param% ' => 'parent_value ' , '%override_param% ' => 'parent_override_value ' ],
203
203
])
204
- ->add ('child ' , $ this ->getTestedType (), [
204
+ ->add ('child ' , $ this ->getTestedType (), array_merge ( $ this -> getTestOptions (), [
205
205
'attr_translation_parameters ' => ['%override_param% ' => 'child_value ' ],
206
- ])
206
+ ]))
207
207
->getForm ()
208
208
->createView ();
209
209
@@ -215,7 +215,7 @@ public function testDefaultLabelTranslationParameters()
215
215
$ this ->requiresFeatureSet (403 );
216
216
217
217
$ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
218
- ->add ('child ' , $ this ->getTestedType ())
218
+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
219
219
->getForm ()
220
220
->createView ();
221
221
@@ -227,7 +227,7 @@ public function testDefaultAttrTranslationParameters()
227
227
$ this ->requiresFeatureSet (403 );
228
228
229
229
$ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
230
- ->add ('child ' , $ this ->getTestedType ())
230
+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
231
231
->getForm ()
232
232
->createView ();
233
233
@@ -236,23 +236,26 @@ public function testDefaultAttrTranslationParameters()
236
236
237
237
public function testPassLabelToView ()
238
238
{
239
- $ view = $ this ->factory ->createNamed ('__test___field ' , $ this ->getTestedType (), null , ['label ' => 'My label ' ])
239
+ $ view = $ this ->factory ->createNamed ('__test___field ' , $ this ->getTestedType (), null , array_merge (
240
+ $ this ->getTestOptions (),
241
+ ['label ' => 'My label ' ]
242
+ ))
240
243
->createView ();
241
244
242
245
$ this ->assertSame ('My label ' , $ view ->vars ['label ' ]);
243
246
}
244
247
245
248
public function testPassMultipartFalseToView ()
246
249
{
247
- $ view = $ this ->factory ->create ($ this ->getTestedType ())
250
+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , $ this -> getTestOptions () )
248
251
->createView ();
249
252
250
253
$ this ->assertFalse ($ view ->vars ['multipart ' ]);
251
254
}
252
255
253
256
public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
254
257
{
255
- $ form = $ this ->factory ->create ($ this ->getTestedType ());
258
+ $ form = $ this ->factory ->create ($ this ->getTestedType (), null , $ this -> getTestOptions () );
256
259
$ form ->submit (null );
257
260
258
261
$ this ->assertSame ($ expected , $ form ->getData ());
@@ -262,7 +265,7 @@ public function testSubmitNull($expected = null, $norm = null, $view = null)
262
265
263
266
public function testSubmitNullUsesDefaultEmptyData ($ emptyData = 'empty ' , $ expectedData = null )
264
267
{
265
- $ builder = $ this ->factory ->createBuilder ($ this ->getTestedType ());
268
+ $ builder = $ this ->factory ->createBuilder ($ this ->getTestedType (), null , $ this -> getTestOptions () );
266
269
267
270
if ($ builder ->getCompound ()) {
268
271
$ emptyData = [];
@@ -286,4 +289,9 @@ protected function getTestedType()
286
289
{
287
290
return static ::TESTED_TYPE ;
288
291
}
292
+
293
+ protected function getTestOptions (): array
294
+ {
295
+ return [];
296
+ }
289
297
}