@@ -2421,4 +2421,59 @@ public function invalidNestedValueTestMatrix()
2421
2421
'multiple, expanded ' => array (true , true , array (array ())),
2422
2422
);
2423
2423
}
2424
+
2425
+ /**
2426
+ * @dataProvider provideTrimCases
2427
+ */
2428
+ public function testTrimIsDisabled ($ multiple , $ expanded )
2429
+ {
2430
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
2431
+ 'multiple ' => $ multiple ,
2432
+ 'expanded ' => $ expanded ,
2433
+ 'choices ' => array (
2434
+ 'a ' => '1 ' ,
2435
+ ),
2436
+ 'choices_as_values ' => true ,
2437
+ ));
2438
+
2439
+ $ submittedData = ' 1 ' ;
2440
+
2441
+ $ form ->submit ($ multiple ? (array ) $ submittedData : $ submittedData );
2442
+
2443
+ // When the choice does not exist the transformation fails
2444
+ $ this ->assertFalse ($ form ->isSynchronized ());
2445
+ $ this ->assertNull ($ form ->getData ());
2446
+ }
2447
+
2448
+ /**
2449
+ * @dataProvider provideTrimCases
2450
+ */
2451
+ public function testSubmitValueWithWhiteSpace ($ multiple , $ expanded )
2452
+ {
2453
+ $ valueWhitWhiteSpace = '1 ' ;
2454
+
2455
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
2456
+ 'multiple ' => $ multiple ,
2457
+ 'expanded ' => $ expanded ,
2458
+ 'choices ' => array (
2459
+ 'a ' => $ valueWhitWhiteSpace ,
2460
+ ),
2461
+ 'choices_as_values ' => true ,
2462
+ ));
2463
+
2464
+ $ form ->submit ($ multiple ? (array ) $ valueWhitWhiteSpace : $ valueWhitWhiteSpace );
2465
+
2466
+ $ this ->assertTrue ($ form ->isSynchronized ());
2467
+ $ this ->assertSame ($ multiple ? (array ) $ valueWhitWhiteSpace : $ valueWhitWhiteSpace , $ form ->getData ());
2468
+ }
2469
+
2470
+ public function provideTrimCases ()
2471
+ {
2472
+ return array (
2473
+ 'Simple ' => array (false , false ),
2474
+ 'Multiple ' => array (true , false ),
2475
+ 'Simple expanded ' => array (false , true ),
2476
+ 'Multiple expanded ' => array (true , true ),
2477
+ );
2478
+ }
2424
2479
}
0 commit comments