@@ -22,7 +22,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
2222 public function testLegacyName ()
2323 {
2424 $ form = $ this ->factory ->create ('collection ' , array (
25- 'type ' => 'text ' ,
25+ 'entry_type ' => 'text ' ,
2626 ));
2727
2828 $ this ->assertSame ('collection ' , $ form ->getConfig ()->getType ()->getName ());
@@ -40,8 +40,8 @@ public function testContainsNoChildByDefault()
4040 public function testSetDataAdjustsSize ()
4141 {
4242 $ 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 (
4545 'attr ' => array ('maxlength ' => 20 ),
4646 ),
4747 ));
@@ -69,7 +69,7 @@ public function testSetDataAdjustsSize()
6969 public function testThrowsExceptionIfObjectIsNotTraversable ()
7070 {
7171 $ 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 ' ,
7373 ));
7474 $ this ->setExpectedException ('Symfony\Component\Form\Exception\UnexpectedTypeException ' );
7575 $ form ->setData (new \stdClass ());
@@ -78,7 +78,7 @@ public function testThrowsExceptionIfObjectIsNotTraversable()
7878 public function testNotResizedIfSubmittedWithMissingData ()
7979 {
8080 $ 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 ' ,
8282 ));
8383 $ form ->setData (array ('foo@foo.com ' , 'bar@bar.com ' ));
8484 $ form ->submit (array ('foo@bar.com ' ));
@@ -92,7 +92,7 @@ public function testNotResizedIfSubmittedWithMissingData()
9292 public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete ()
9393 {
9494 $ 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 ' ,
9696 'allow_delete ' => true ,
9797 ));
9898 $ form ->setData (array ('foo@foo.com ' , 'bar@bar.com ' ));
@@ -107,7 +107,7 @@ public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete()
107107 public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty ()
108108 {
109109 $ 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 ' ,
111111 'allow_delete ' => true ,
112112 'delete_empty ' => true ,
113113 ));
@@ -124,7 +124,7 @@ public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty()
124124 public function testDontAddEmptyDataIfDeleteEmpty ()
125125 {
126126 $ 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 ' ,
128128 'allow_add ' => true ,
129129 'delete_empty ' => true ,
130130 ));
@@ -141,7 +141,7 @@ public function testDontAddEmptyDataIfDeleteEmpty()
141141 public function testNoDeleteEmptyIfDeleteNotAllowed ()
142142 {
143143 $ 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 ' ,
145145 'allow_delete ' => false ,
146146 'delete_empty ' => true ,
147147 ));
@@ -156,10 +156,10 @@ public function testNoDeleteEmptyIfDeleteNotAllowed()
156156 public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty ()
157157 {
158158 $ 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 ' ,
160160 // If the field is not required, no new Author will be created if the
161161 // form is completely empty
162- 'options ' => array ('required ' => false ),
162+ 'entry_options ' => array ('required ' => false ),
163163 'allow_add ' => true ,
164164 'delete_empty ' => true ,
165165 ));
@@ -179,7 +179,7 @@ public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty()
179179 public function testNotResizedIfSubmittedWithExtraData ()
180180 {
181181 $ 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 ' ,
183183 ));
184184 $ form ->setData (array ('foo@bar.com ' ));
185185 $ form ->submit (array ('foo@foo.com ' , 'bar@bar.com ' ));
@@ -192,7 +192,7 @@ public function testNotResizedIfSubmittedWithExtraData()
192192 public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd ()
193193 {
194194 $ 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 ' ,
196196 'allow_add ' => true ,
197197 ));
198198 $ form ->setData (array ('foo@bar.com ' ));
@@ -208,7 +208,7 @@ public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd()
208208 public function testAllowAddButNoPrototype ()
209209 {
210210 $ 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 ' ,
212212 'allow_add ' => true ,
213213 'prototype ' => false ,
214214 ));
@@ -220,7 +220,7 @@ public function testPrototypeMultipartPropagation()
220220 {
221221 $ form = $ this ->factory
222222 ->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 ' ,
224224 'allow_add ' => true ,
225225 'prototype ' => true ,
226226 ))
@@ -232,7 +232,7 @@ public function testPrototypeMultipartPropagation()
232232 public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet ()
233233 {
234234 $ 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 ' ,
236236 'prototype ' => true ,
237237 'allow_add ' => true ,
238238 ));
@@ -244,7 +244,7 @@ public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet()
244244 public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet ()
245245 {
246246 $ 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 ' ,
248248 'allow_add ' => true ,
249249 'prototype ' => true ,
250250 ));
@@ -257,15 +257,15 @@ public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
257257 public function testPrototypeNameOption ()
258258 {
259259 $ 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 ' ,
261261 'prototype ' => true ,
262262 'allow_add ' => true ,
263263 ));
264264
265265 $ this ->assertSame ('__name__ ' , $ form ->getConfig ()->getAttribute ('prototype ' )->getName (), '__name__ is the default ' );
266266
267267 $ 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 ' ,
269269 'prototype ' => true ,
270270 'allow_add ' => true ,
271271 'prototype_name ' => '__test__ ' ,
@@ -274,10 +274,26 @@ public function testPrototypeNameOption()
274274 $ this ->assertSame ('__test__ ' , $ form ->getConfig ()->getAttribute ('prototype ' )->getName ());
275275 }
276276
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+
277293 public function testPrototypeDefaultLabel ()
278294 {
279295 $ 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 ' ,
281297 'allow_add ' => true ,
282298 'prototype ' => true ,
283299 'prototype_name ' => '__test__ ' ,
@@ -293,7 +309,7 @@ public function testPrototypeData()
293309 'allow_add ' => true ,
294310 'prototype ' => true ,
295311 'prototype_data ' => 'foo ' ,
296- 'options ' => array (
312+ 'entry_options ' => array (
297313 'data ' => 'bar ' ,
298314 ),
299315 ));
0 commit comments