@@ -737,7 +737,7 @@ function ($object, $key, $value) {
737
737
/**
738
738
* @group legacy
739
739
*/
740
- public function testCreateViewForLegacyChoiceList ()
740
+ public function testCreateViewForFlatLegacyChoiceList ()
741
741
{
742
742
// legacy ChoiceList instances provide legacy ChoiceView objects
743
743
$ preferred = array (new LegacyChoiceView ('x ' , 'x ' , 'Preferred ' ));
@@ -758,6 +758,36 @@ public function testCreateViewForLegacyChoiceList()
758
758
$ this ->assertEquals (array (new ChoiceView ('x ' , 'x ' , 'Preferred ' )), $ view ->preferredChoices );
759
759
}
760
760
761
+ /**
762
+ * @group legacy
763
+ */
764
+ public function testCreateViewForNestedLegacyChoiceList ()
765
+ {
766
+ // legacy ChoiceList instances provide legacy ChoiceView objects
767
+ $ preferred = array ('Section 1 ' => array (new LegacyChoiceView ('x ' , 'x ' , 'Preferred ' )));
768
+ $ other = array (
769
+ 'Section 2 ' => array (new LegacyChoiceView ('y ' , 'y ' , 'Other ' )),
770
+ new LegacyChoiceView ('z ' , 'z ' , 'Other one ' ),
771
+ );
772
+
773
+ $ list = $ this ->getMock ('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface ' );
774
+
775
+ $ list ->expects ($ this ->once ())
776
+ ->method ('getPreferredViews ' )
777
+ ->will ($ this ->returnValue ($ preferred ));
778
+ $ list ->expects ($ this ->once ())
779
+ ->method ('getRemainingViews ' )
780
+ ->will ($ this ->returnValue ($ other ));
781
+
782
+ $ view = $ this ->factory ->createView (new LegacyChoiceListAdapter ($ list ));
783
+
784
+ $ this ->assertEquals (array (
785
+ 'Section 2 ' => array (new ChoiceView ('y ' , 'y ' , 'Other ' )),
786
+ new ChoiceView ('z ' , 'z ' , 'Other one ' ),
787
+ ), $ view ->choices );
788
+ $ this ->assertEquals (array ('Section 1 ' => array (new ChoiceView ('x ' , 'x ' , 'Preferred ' ))), $ view ->preferredChoices );
789
+ }
790
+
761
791
private function assertScalarListWithChoiceValues (ChoiceListInterface $ list )
762
792
{
763
793
$ this ->assertSame (array ('a ' , 'b ' , 'c ' , 'd ' ), $ list ->getValues ());
0 commit comments