@@ -737,7 +737,7 @@ function ($object, $key, $value) {
737737 /**
738738 * @group legacy
739739 */
740- public function testCreateViewForLegacyChoiceList ()
740+ public function testCreateViewForFlatLegacyChoiceList ()
741741 {
742742 // legacy ChoiceList instances provide legacy ChoiceView objects
743743 $ preferred = array (new LegacyChoiceView ('x ' , 'x ' , 'Preferred ' ));
@@ -758,6 +758,36 @@ public function testCreateViewForLegacyChoiceList()
758758 $ this ->assertEquals (array (new ChoiceView ('x ' , 'x ' , 'Preferred ' )), $ view ->preferredChoices );
759759 }
760760
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+
761791 private function assertScalarListWithChoiceValues (ChoiceListInterface $ list )
762792 {
763793 $ this ->assertSame (array ('a ' , 'b ' , 'c ' , 'd ' ), $ list ->getValues ());
0 commit comments