@@ -123,6 +123,7 @@ public function testBuildPreliminaryFormTree()
123123'config ' =>'foo ' ,
124124'default_data ' =>'foo ' ,
125125'submitted_data ' =>'foo ' ,
126+ 'expanded ' =>false ,
126127'children ' =>array (
127128'child ' =>$ childFormData ,
128129 ),
@@ -323,6 +324,7 @@ public function testBuildFinalFormTree()
323324'config ' =>'foo ' ,
324325'default_data ' =>'foo ' ,
325326'submitted_data ' =>'foo ' ,
327+ 'expanded ' =>false ,
326328'children ' =>array (
327329'child ' =>$ childFormData ,
328330 ),
@@ -528,6 +530,62 @@ public function testCollectSubmittedDataCountsErrors()
528530$ this ->assertSame (4 ,$ data ['nb_errors ' ]);
529531 }
530532
533+ public function testCollectSubmittedDataExpandedFormsErrors ()
534+ {
535+ $ child1Form =$ this ->createForm ('child1 ' );
536+ $ child11Form =$ this ->createForm ('child11 ' );
537+ $ child2Form =$ this ->createForm ('child2 ' );
538+ $ child21Form =$ this ->createForm ('child21 ' );
539+
540+ $ child1Form ->add ($ child11Form );
541+ $ child2Form ->add ($ child21Form );
542+ $ this ->form ->add ($ child1Form );
543+ $ this ->form ->add ($ child2Form );
544+
545+ $ this ->dataExtractor
546+ ->method ('extractConfiguration ' )
547+ ->will ($ this ->returnValue (array ()));
548+ $ this ->dataExtractor
549+ ->method ('extractDefaultData ' )
550+ ->will ($ this ->returnValue (array ()));
551+ $ this ->dataExtractor ->expects ($ this ->at (10 ))
552+ ->method ('extractSubmittedData ' )
553+ ->with ($ this ->form )
554+ ->will ($ this ->returnValue (array ('errors ' =>array ())));
555+ $ this ->dataExtractor ->expects ($ this ->at (11 ))
556+ ->method ('extractSubmittedData ' )
557+ ->with ($ child1Form )
558+ ->will ($ this ->returnValue (array ('errors ' =>array ())));
559+ $ this ->dataExtractor ->expects ($ this ->at (12 ))
560+ ->method ('extractSubmittedData ' )
561+ ->with ($ child11Form )
562+ ->will ($ this ->returnValue (array ('errors ' =>array ('foo ' ))));
563+ $ this ->dataExtractor ->expects ($ this ->at (13 ))
564+ ->method ('extractSubmittedData ' )
565+ ->with ($ child2Form )
566+ ->will ($ this ->returnValue (array ('errors ' =>array ())));
567+ $ this ->dataExtractor ->expects ($ this ->at (14 ))
568+ ->method ('extractSubmittedData ' )
569+ ->with ($ child21Form )
570+ ->will ($ this ->returnValue (array ('errors ' =>array ())));
571+
572+ $ this ->dataCollector ->collectSubmittedData ($ this ->form );
573+ $ this ->dataCollector ->buildPreliminaryFormTree ($ this ->form );
574+
575+ $ data =$ this ->dataCollector ->getData ();
576+ $ formData =$ data ['forms ' ]['name ' ];
577+ $ child1Data =$ formData ['children ' ]['child1 ' ];
578+ $ child11Data =$ child1Data ['children ' ]['child11 ' ];
579+ $ child2Data =$ formData ['children ' ]['child2 ' ];
580+ $ child21Data =$ child2Data ['children ' ]['child21 ' ];
581+
582+ $ this ->assertTrue ($ formData ['expanded ' ]);
583+ $ this ->assertTrue ($ child1Data ['expanded ' ]);
584+ $ this ->assertFalse (isset ($ child11Data ['expanded ' ]),'The leaf data does not contains "expanded" property. ' );
585+ $ this ->assertFalse ($ child2Data ['expanded ' ]);
586+ $ this ->assertFalse (isset ($ child21Data ['expanded ' ]),'The leaf data does not contains "expanded" property. ' );
587+ }
588+
531589private function createForm ($ name )
532590 {
533591$ builder =new FormBuilder ($ name ,null ,$ this ->dispatcher ,$ this ->factory );