@@ -1321,6 +1321,31 @@ public function testSubmitSingleExpandedObjectChoices()
1321
1321
$ this ->assertNull ($ form [4 ]->getViewData ());
1322
1322
}
1323
1323
1324
+ public function testSubmitSingleExpandedFilteredObjectChoices ()
1325
+ {
1326
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , [
1327
+ 'multiple ' => false ,
1328
+ 'expanded ' => true ,
1329
+ 'choices ' => $ this ->objectChoices ,
1330
+ 'choice_label ' => 'name ' ,
1331
+ 'choice_value ' => 'id ' ,
1332
+ 'choice_filter ' => function ($ choice ) { return null === $ choice || $ choice ->id < 4 ; },
1333
+ ]);
1334
+
1335
+ $ form ->submit ('2 ' );
1336
+
1337
+ $ this ->assertSame ($ this ->objectChoices [1 ], $ form ->getData ());
1338
+ $ this ->assertTrue ($ form ->isSynchronized ());
1339
+
1340
+ $ this ->assertFalse ($ form [0 ]->getData ());
1341
+ $ this ->assertTrue ($ form [1 ]->getData ());
1342
+ $ this ->assertFalse ($ form [2 ]->getData ());
1343
+ $ this ->assertFalse (isset ($ form [3 ]));
1344
+ $ this ->assertNull ($ form [0 ]->getViewData ());
1345
+ $ this ->assertSame ('2 ' , $ form [1 ]->getViewData ());
1346
+ $ this ->assertNull ($ form [2 ]->getViewData ());
1347
+ }
1348
+
1324
1349
public function testSubmitSingleExpandedClearMissingFalse ()
1325
1350
{
1326
1351
$ form = $ this ->factory ->create (self ::TESTED_TYPE , 'foo ' , [
@@ -1510,6 +1535,31 @@ public function testSubmitMultipleExpandedObjectChoices()
1510
1535
$ this ->assertNull ($ form [4 ]->getViewData ());
1511
1536
}
1512
1537
1538
+ public function testSubmitMultipleExpandedFilteredObjectChoices ()
1539
+ {
1540
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , [
1541
+ 'multiple ' => true ,
1542
+ 'expanded ' => true ,
1543
+ 'choices ' => $ this ->objectChoices ,
1544
+ 'choice_label ' => 'name ' ,
1545
+ 'choice_value ' => 'id ' ,
1546
+ 'choice_filter ' => function ($ choice ) { return null === $ choice || $ choice ->id < 4 ; },
1547
+ ]);
1548
+
1549
+ $ form ->submit (['1 ' , '2 ' ]);
1550
+
1551
+ $ this ->assertSame ([$ this ->objectChoices [0 ], $ this ->objectChoices [1 ]], $ form ->getData ());
1552
+ $ this ->assertTrue ($ form ->isSynchronized ());
1553
+
1554
+ $ this ->assertTrue ($ form [0 ]->getData ());
1555
+ $ this ->assertTrue ($ form [1 ]->getData ());
1556
+ $ this ->assertFalse ($ form [2 ]->getData ());
1557
+ $ this ->assertFalse (isset ($ form [3 ]));
1558
+ $ this ->assertSame ('1 ' , $ form [0 ]->getViewData ());
1559
+ $ this ->assertSame ('2 ' , $ form [1 ]->getViewData ());
1560
+ $ this ->assertNull ($ form [2 ]->getViewData ());
1561
+ }
1562
+
1513
1563
public function testSubmitMultipleChoicesInts ()
1514
1564
{
1515
1565
$ form = $ this ->factory ->create (static ::TESTED_TYPE , null , [
0 commit comments