getData() public method

public getData ( )
示例#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 testCollectSubmittedDataCountsErrors()
 {
     $form1 = $this->createForm('form1');
     $childForm1 = $this->createForm('child1');
     $form2 = $this->createForm('form2');
     $form1->add($childForm1);
     $this->dataExtractor->expects($this->at(0))->method('extractSubmittedData')->with($form1)->will($this->returnValue(array('errors' => array('foo'))));
     $this->dataExtractor->expects($this->at(1))->method('extractSubmittedData')->with($childForm1)->will($this->returnValue(array('errors' => array('bar', 'bam'))));
     $this->dataExtractor->expects($this->at(2))->method('extractSubmittedData')->with($form2)->will($this->returnValue(array('errors' => array('baz'))));
     $this->dataCollector->collectSubmittedData($form1);
     $data = $this->dataCollector->getData();
     $this->assertSame(3, $data['nb_errors']);
     $this->dataCollector->collectSubmittedData($form2);
     $data = $this->dataCollector->getData();
     $this->assertSame(4, $data['nb_errors']);
 }