buildPreliminaryFormTree() public method

public buildPreliminaryFormTree ( Symfony\Component\Form\FormInterface $form )
$form Symfony\Component\Form\FormInterface
示例#1
0
 public function testCollectSubmittedDataExpandedFormsErrors()
 {
     $child1Form = $this->createForm('child1');
     $child11Form = $this->createForm('child11');
     $child2Form = $this->createForm('child2');
     $child21Form = $this->createForm('child21');
     $child1Form->add($child11Form);
     $child2Form->add($child21Form);
     $this->form->add($child1Form);
     $this->form->add($child2Form);
     $this->dataExtractor->method('extractConfiguration')->will($this->returnValue(array()));
     $this->dataExtractor->method('extractDefaultData')->will($this->returnValue(array()));
     $this->dataExtractor->expects($this->at(10))->method('extractSubmittedData')->with($this->form)->will($this->returnValue(array('errors' => array())));
     $this->dataExtractor->expects($this->at(11))->method('extractSubmittedData')->with($child1Form)->will($this->returnValue(array('errors' => array())));
     $this->dataExtractor->expects($this->at(12))->method('extractSubmittedData')->with($child11Form)->will($this->returnValue(array('errors' => array('foo'))));
     $this->dataExtractor->expects($this->at(13))->method('extractSubmittedData')->with($child2Form)->will($this->returnValue(array('errors' => array())));
     $this->dataExtractor->expects($this->at(14))->method('extractSubmittedData')->with($child21Form)->will($this->returnValue(array('errors' => array())));
     $this->dataCollector->collectSubmittedData($this->form);
     $this->dataCollector->buildPreliminaryFormTree($this->form);
     $data = $this->dataCollector->getData();
     $formData = $data['forms']['name'];
     $child1Data = $formData['children']['child1'];
     $child11Data = $child1Data['children']['child11'];
     $child2Data = $formData['children']['child2'];
     $child21Data = $child2Data['children']['child21'];
     $this->assertTrue($formData['has_children_error']);
     $this->assertTrue($child1Data['has_children_error']);
     $this->assertFalse(isset($child11Data['has_children_error']), 'The leaf data does not contains "has_children_error" property.');
     $this->assertFalse($child2Data['has_children_error']);
     $this->assertFalse(isset($child21Data['has_children_error']), 'The leaf data does not contains "has_children_error" property.');
 }
 public function testFinalFormReliesOnFormViewStructure()
 {
     $this->form->add($this->createForm('first'));
     $this->form->add($this->createForm('second'));
     $this->view->children['second'] = $this->childView;
     $this->dataCollector->buildPreliminaryFormTree($this->form);
     $this->assertSame(array('forms' => array('name' => array('children' => array('first' => array('children' => array()), 'second' => array('children' => array())))), 'nb_errors' => 0), $this->dataCollector->getData());
     $this->dataCollector->buildFinalFormTree($this->form, $this->view);
     $this->assertSame(array('forms' => array('name' => array('children' => array('second' => array('children' => array())))), 'nb_errors' => 0), $this->dataCollector->getData());
 }
 public function testFinalFormReliesOnFormViewStructure()
 {
     $this->form->add($child1 = $this->createForm('first'));
     $this->form->add($child2 = $this->createForm('second'));
     $this->view->children['second'] = $this->childView;
     $this->dataCollector->buildPreliminaryFormTree($this->form);
     $child1Data = array('children' => array());
     $child2Data = array('children' => array());
     $formData = array('children' => array('first' => $child1Data, 'second' => $child2Data));
     $this->assertSame(array('forms' => array('name' => $formData), 'forms_by_hash' => array(spl_object_hash($this->form) => $formData, spl_object_hash($child1) => $child1Data, spl_object_hash($child2) => $child2Data), 'nb_errors' => 0), $this->dataCollector->getData());
     $this->dataCollector->buildFinalFormTree($this->form, $this->view);
     $formData = array('children' => array('second' => $child2Data));
     $this->assertSame(array('forms' => array('name' => $formData), 'forms_by_hash' => array(spl_object_hash($this->form) => $formData, spl_object_hash($child1) => $child1Data, spl_object_hash($child2) => $child2Data), 'nb_errors' => 0), $this->dataCollector->getData());
 }