@@ -22,7 +22,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
22
22
public function testLegacyName ()
23
23
{
24
24
$ form = $ this ->factory ->create ('collection ' , array (
25
- 'type ' => 'text ' ,
25
+ 'entry_type ' => 'text ' ,
26
26
));
27
27
28
28
$ this ->assertSame ('collection ' , $ form ->getConfig ()->getType ()->getName ());
@@ -40,8 +40,8 @@ public function testContainsNoChildByDefault()
40
40
public function testSetDataAdjustsSize ()
41
41
{
42
42
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
43
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
44
- 'options ' => array (
43
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
44
+ 'entry_options ' => array (
45
45
'attr ' => array ('maxlength ' => 20 ),
46
46
),
47
47
));
@@ -69,7 +69,7 @@ public function testSetDataAdjustsSize()
69
69
public function testThrowsExceptionIfObjectIsNotTraversable ()
70
70
{
71
71
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
72
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
72
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
73
73
));
74
74
$ this ->setExpectedException ('Symfony\Component\Form\Exception\UnexpectedTypeException ' );
75
75
$ form ->setData (new \stdClass ());
@@ -78,7 +78,7 @@ public function testThrowsExceptionIfObjectIsNotTraversable()
78
78
public function testNotResizedIfSubmittedWithMissingData ()
79
79
{
80
80
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
81
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
81
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
82
82
));
83
83
$ form ->setData (array ('foo@foo.com ' , 'bar@bar.com ' ));
84
84
$ form ->submit (array ('foo@bar.com ' ));
@@ -92,7 +92,7 @@ public function testNotResizedIfSubmittedWithMissingData()
92
92
public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete ()
93
93
{
94
94
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
95
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
95
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
96
96
'allow_delete ' => true ,
97
97
));
98
98
$ form ->setData (array ('foo@foo.com ' , 'bar@bar.com ' ));
@@ -107,7 +107,7 @@ public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete()
107
107
public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty ()
108
108
{
109
109
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
110
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
110
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
111
111
'allow_delete ' => true ,
112
112
'delete_empty ' => true ,
113
113
));
@@ -124,7 +124,7 @@ public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty()
124
124
public function testDontAddEmptyDataIfDeleteEmpty ()
125
125
{
126
126
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
127
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
127
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
128
128
'allow_add ' => true ,
129
129
'delete_empty ' => true ,
130
130
));
@@ -141,7 +141,7 @@ public function testDontAddEmptyDataIfDeleteEmpty()
141
141
public function testNoDeleteEmptyIfDeleteNotAllowed ()
142
142
{
143
143
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
144
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
144
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
145
145
'allow_delete ' => false ,
146
146
'delete_empty ' => true ,
147
147
));
@@ -156,10 +156,10 @@ public function testNoDeleteEmptyIfDeleteNotAllowed()
156
156
public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty ()
157
157
{
158
158
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
159
- 'type ' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType ' ,
159
+ 'entry_type ' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType ' ,
160
160
// If the field is not required, no new Author will be created if the
161
161
// form is completely empty
162
- 'options ' => array ('required ' => false ),
162
+ 'entry_options ' => array ('required ' => false ),
163
163
'allow_add ' => true ,
164
164
'delete_empty ' => true ,
165
165
));
@@ -179,7 +179,7 @@ public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty()
179
179
public function testNotResizedIfSubmittedWithExtraData ()
180
180
{
181
181
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
182
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
182
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
183
183
));
184
184
$ form ->setData (array ('foo@bar.com ' ));
185
185
$ form ->submit (array ('foo@foo.com ' , 'bar@bar.com ' ));
@@ -192,7 +192,7 @@ public function testNotResizedIfSubmittedWithExtraData()
192
192
public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd ()
193
193
{
194
194
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
195
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
195
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
196
196
'allow_add ' => true ,
197
197
));
198
198
$ form ->setData (array ('foo@bar.com ' ));
@@ -208,7 +208,7 @@ public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd()
208
208
public function testAllowAddButNoPrototype ()
209
209
{
210
210
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
211
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\FormType ' ,
211
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\FormType ' ,
212
212
'allow_add ' => true ,
213
213
'prototype ' => false ,
214
214
));
@@ -220,7 +220,7 @@ public function testPrototypeMultipartPropagation()
220
220
{
221
221
$ form = $ this ->factory
222
222
->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
223
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
223
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
224
224
'allow_add ' => true ,
225
225
'prototype ' => true ,
226
226
))
@@ -232,7 +232,7 @@ public function testPrototypeMultipartPropagation()
232
232
public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet ()
233
233
{
234
234
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , array (), array (
235
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
235
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
236
236
'prototype ' => true ,
237
237
'allow_add ' => true ,
238
238
));
@@ -244,7 +244,7 @@ public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet()
244
244
public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet ()
245
245
{
246
246
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , array (), array (
247
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
247
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
248
248
'allow_add ' => true ,
249
249
'prototype ' => true ,
250
250
));
@@ -257,15 +257,15 @@ public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
257
257
public function testPrototypeNameOption ()
258
258
{
259
259
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
260
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\FormType ' ,
260
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\FormType ' ,
261
261
'prototype ' => true ,
262
262
'allow_add ' => true ,
263
263
));
264
264
265
265
$ this ->assertSame ('__name__ ' , $ form ->getConfig ()->getAttribute ('prototype ' )->getName (), '__name__ is the default ' );
266
266
267
267
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , null , array (
268
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\FormType ' ,
268
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\FormType ' ,
269
269
'prototype ' => true ,
270
270
'allow_add ' => true ,
271
271
'prototype_name ' => '__test__ ' ,
@@ -274,10 +274,26 @@ public function testPrototypeNameOption()
274
274
$ this ->assertSame ('__test__ ' , $ form ->getConfig ()->getAttribute ('prototype ' )->getName ());
275
275
}
276
276
277
+ /**
278
+ * @group legacy
279
+ */
280
+ public function testLegacyEntryOptions ()
281
+ {
282
+ $ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , array (), array (
283
+ 'type ' => 'Symfony\Component\Form\Extension\Core\Type\NumberType ' ,
284
+ 'options ' => array ('attr ' => array ('maxlength ' => '10 ' )),
285
+ ));
286
+
287
+ $ resolvedOptions = $ form ->getConfig ()->getOptions ();
288
+
289
+ $ this ->assertEquals ('Symfony\Component\Form\Extension\Core\Type\NumberType ' , $ resolvedOptions ['entry_type ' ]);
290
+ $ this ->assertEquals (array ('attr ' => array ('maxlength ' => '10 ' ), 'block_name ' => 'entry ' ), $ resolvedOptions ['entry_options ' ]);
291
+ }
292
+
277
293
public function testPrototypeDefaultLabel ()
278
294
{
279
295
$ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , array (), array (
280
- 'type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
296
+ 'entry_type ' => 'Symfony\Component\Form\Extension\Core\Type\FileType ' ,
281
297
'allow_add ' => true ,
282
298
'prototype ' => true ,
283
299
'prototype_name ' => '__test__ ' ,
@@ -293,7 +309,7 @@ public function testPrototypeData()
293
309
'allow_add ' => true ,
294
310
'prototype ' => true ,
295
311
'prototype_data ' => 'foo ' ,
296
- 'options ' => array (
312
+ 'entry_options ' => array (
297
313
'data ' => 'bar ' ,
298
314
),
299
315
));
0 commit comments