Symfony\Component\Form\Tests\Extension\DataCollector\FormDataCollectorTest::testBuildMultiplePreliminaryFormTrees PHP Method

testBuildMultiplePreliminaryFormTrees() public method

    public function testBuildMultiplePreliminaryFormTrees()
    {
        $form1 = $this->createForm('form1');
        $form2 = $this->createForm('form2');

        $this->dataExtractor->expects($this->at(0))
            ->method('extractConfiguration')
            ->with($form1)
            ->will($this->returnValue(array('config' => 'foo')));
        $this->dataExtractor->expects($this->at(1))
            ->method('extractConfiguration')
            ->with($form2)
            ->will($this->returnValue(array('config' => 'bar')));

        $this->dataCollector->collectConfiguration($form1);
        $this->dataCollector->collectConfiguration($form2);
        $this->dataCollector->buildPreliminaryFormTree($form1);

        $form1Data = array(
            'config' => 'foo',
            'children' => array(),
        );

        $this->assertSame(array(
            'forms' => array(
                'form1' => $form1Data,
            ),
            'forms_by_hash' => array(
                spl_object_hash($form1) => $form1Data,
            ),
            'nb_errors' => 0,
        ), $this->dataCollector->getData());

        $this->dataCollector->buildPreliminaryFormTree($form2);

        $form2Data = array(
            'config' => 'bar',
            'children' => array(),
        );

        $this->assertSame(array(
            'forms' => array(
                'form1' => $form1Data,
                'form2' => $form2Data,
            ),
            'forms_by_hash' => array(
                spl_object_hash($form1) => $form1Data,
                spl_object_hash($form2) => $form2Data,
            ),
            'nb_errors' => 0,
        ), $this->dataCollector->getData());
    }