@@ -25,14 +25,14 @@ abstract class BaseTypeTest extends TypeTestCase
2525
2626 public function testPassDisabledAsOption ()
2727 {
28- $ form = $ this ->factory ->create ($ this ->getTestedType (), null , ['disabled ' => true ]);
28+ $ form = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), ['disabled ' => true ]) );
2929
3030 $ this ->assertTrue ($ form ->isDisabled ());
3131 }
3232
3333 public function testPassIdAndNameToView ()
3434 {
35- $ view = $ this ->factory ->createNamed ('name ' , $ this ->getTestedType ())
35+ $ view = $ this ->factory ->createNamed ('name ' , $ this ->getTestedType (), null , $ this -> getTestOptions () )
3636 ->createView ();
3737
3838 $ this ->assertEquals ('name ' , $ view ->vars ['id ' ]);
@@ -42,7 +42,7 @@ public function testPassIdAndNameToView()
4242
4343 public function testStripLeadingUnderscoresAndDigitsFromId ()
4444 {
45- $ view = $ this ->factory ->createNamed ('_09name ' , $ this ->getTestedType ())
45+ $ view = $ this ->factory ->createNamed ('_09name ' , $ this ->getTestedType (), null , $ this -> getTestOptions () )
4646 ->createView ();
4747
4848 $ this ->assertEquals ('name ' , $ view ->vars ['id ' ]);
@@ -53,7 +53,7 @@ public function testStripLeadingUnderscoresAndDigitsFromId()
5353 public function testPassIdAndNameToViewWithParent ()
5454 {
5555 $ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
56- ->add ('child ' , $ this ->getTestedType ())
56+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
5757 ->getForm ()
5858 ->createView ();
5959
@@ -66,7 +66,7 @@ public function testPassIdAndNameToViewWithGrandParent()
6666 {
6767 $ builder = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
6868 ->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 () );
7070 $ view = $ builder ->getForm ()->createView ();
7171
7272 $ this ->assertEquals ('parent_child_grand_child ' , $ view ['child ' ]['grand_child ' ]->vars ['id ' ]);
@@ -76,9 +76,9 @@ public function testPassIdAndNameToViewWithGrandParent()
7676
7777 public function testPassTranslationDomainToView ()
7878 {
79- $ view = $ this ->factory ->create ($ this ->getTestedType (), null , [
79+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), [
8080 'translation_domain ' => 'domain ' ,
81- ])
81+ ]))
8282 ->createView ();
8383
8484 $ this ->assertSame ('domain ' , $ view ->vars ['translation_domain ' ]);
@@ -90,7 +90,7 @@ public function testInheritTranslationDomainFromParent()
9090 ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
9191 'translation_domain ' => 'domain ' ,
9292 ])
93- ->add ('child ' , $ this ->getTestedType ())
93+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
9494 ->getForm ()
9595 ->createView ();
9696
@@ -103,9 +103,9 @@ public function testPreferOwnTranslationDomain()
103103 ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
104104 'translation_domain ' => 'parent_domain ' ,
105105 ])
106- ->add ('child ' , $ this ->getTestedType (), [
106+ ->add ('child ' , $ this ->getTestedType (), array_merge ( $ this -> getTestOptions (), [
107107 'translation_domain ' => 'domain ' ,
108- ])
108+ ]))
109109 ->getForm ()
110110 ->createView ();
111111
@@ -115,7 +115,7 @@ public function testPreferOwnTranslationDomain()
115115 public function testDefaultTranslationDomain ()
116116 {
117117 $ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
118- ->add ('child ' , $ this ->getTestedType ())
118+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
119119 ->getForm ()
120120 ->createView ();
121121
@@ -126,9 +126,9 @@ public function testPassLabelTranslationParametersToView()
126126 {
127127 $ this ->requiresFeatureSet (403 );
128128
129- $ view = $ this ->factory ->create ($ this ->getTestedType (), null , [
129+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), [
130130 'label_translation_parameters ' => ['%param% ' => 'value ' ],
131- ])
131+ ]))
132132 ->createView ();
133133
134134 $ this ->assertSame (['%param% ' => 'value ' ], $ view ->vars ['label_translation_parameters ' ]);
@@ -138,9 +138,9 @@ public function testPassAttrTranslationParametersToView()
138138 {
139139 $ this ->requiresFeatureSet (403 );
140140
141- $ view = $ this ->factory ->create ($ this ->getTestedType (), null , [
141+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , array_merge ( $ this -> getTestOptions (), [
142142 'attr_translation_parameters ' => ['%param% ' => 'value ' ],
143- ])
143+ ]))
144144 ->createView ();
145145
146146 $ this ->assertSame (['%param% ' => 'value ' ], $ view ->vars ['attr_translation_parameters ' ]);
@@ -154,7 +154,7 @@ public function testInheritLabelTranslationParametersFromParent()
154154 ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
155155 'label_translation_parameters ' => ['%param% ' => 'value ' ],
156156 ])
157- ->add ('child ' , $ this ->getTestedType ())
157+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
158158 ->getForm ()
159159 ->createView ();
160160
@@ -169,7 +169,7 @@ public function testInheritAttrTranslationParametersFromParent()
169169 ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
170170 'attr_translation_parameters ' => ['%param% ' => 'value ' ],
171171 ])
172- ->add ('child ' , $ this ->getTestedType ())
172+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
173173 ->getForm ()
174174 ->createView ();
175175
@@ -184,9 +184,9 @@ public function testPreferOwnLabelTranslationParameters()
184184 ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
185185 'label_translation_parameters ' => ['%parent_param% ' => 'parent_value ' , '%override_param% ' => 'parent_override_value ' ],
186186 ])
187- ->add ('child ' , $ this ->getTestedType (), [
187+ ->add ('child ' , $ this ->getTestedType (), array_merge ( $ this -> getTestOptions (), [
188188 'label_translation_parameters ' => ['%override_param% ' => 'child_value ' ],
189- ])
189+ ]))
190190 ->getForm ()
191191 ->createView ();
192192
@@ -201,9 +201,9 @@ public function testPreferOwnAttrTranslationParameters()
201201 ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE , null , [
202202 'attr_translation_parameters ' => ['%parent_param% ' => 'parent_value ' , '%override_param% ' => 'parent_override_value ' ],
203203 ])
204- ->add ('child ' , $ this ->getTestedType (), [
204+ ->add ('child ' , $ this ->getTestedType (), array_merge ( $ this -> getTestOptions (), [
205205
D306
'attr_translation_parameters ' => ['%override_param% ' => 'child_value ' ],
206- ])
206+ ]))
207207 ->getForm ()
208208 ->createView ();
209209
@@ -215,7 +215,7 @@ public function testDefaultLabelTranslationParameters()
215215 $ this ->requiresFeatureSet (403 );
216216
217217 $ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
218- ->add ('child ' , $ this ->getTestedType ())
218+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
219219 ->getForm ()
220220 ->createView ();
221221
@@ -227,7 +227,7 @@ public function testDefaultAttrTranslationParameters()
227227 $ this ->requiresFeatureSet (403 );
228228
229229 $ view = $ this ->factory ->createNamedBuilder ('parent ' , FormTypeTest::TESTED_TYPE )
230- ->add ('child ' , $ this ->getTestedType ())
230+ ->add ('child ' , $ this ->getTestedType (), $ this -> getTestOptions () )
231231 ->getForm ()
232232 ->createView ();
233233
@@ -236,23 +236,26 @@ public function testDefaultAttrTranslationParameters()
236236
237237 public function testPassLabelToView ()
238238 {
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+ ))
240243 ->createView ();
241244
242245 $ this ->assertSame ('My label ' , $ view ->vars ['label ' ]);
243246 }
244247
245248 public function testPassMultipartFalseToView ()
246249 {
247- $ view = $ this ->factory ->create ($ this ->getTestedType ())
250+ $ view = $ this ->factory ->create ($ this ->getTestedType (), null , $ this -> getTestOptions () )
248251 ->createView ();
249252
250253 $ this ->assertFalse ($ view ->vars ['multipart ' ]);
251254 }
252255
253256 public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
254257 {
255- $ form = $ this ->factory ->create ($ this ->getTestedType ());
258+ $ form = $ this ->factory ->create ($ this ->getTestedType (), null , $ this -> getTestOptions () );
256259 $ form ->submit (null );
257260
258261 $ this ->assertSame ($ expected , $ form ->getData ());
@@ -262,7 +265,7 @@ public function testSubmitNull($expected = null, $norm = null, $view = null)
262265
263266 public function testSubmitNullUsesDefaultEmptyData ($ emptyData = 'empty ' , $ expectedData = null )
264267 {
265- $ builder = $ this ->factory ->createBuilder ($ this ->getTestedType ());
268+ $ builder = $ this ->factory ->createBuilder ($ this ->getTestedType (), null , $ this -> getTestOptions () );
266269
267270 if ($ builder ->getCompound ()) {
268271 $ emptyData = [];
@@ -286,4 +289,9 @@ protected function getTestedType()
286289 {
287290 return static ::TESTED_TYPE ;
288291 }
292+
293+ protected function getTestOptions (): array
294+ {
295+ return [];
296+ }
289297}
0 commit comments