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

testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssociated() public method

    public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssociated()
    {
        // don't add $this->childForm to $this->form!

        $this->view->children['child'] = $this->childView;

        // but associate the two
        $this->dataCollector->associateFormWithView($this->childForm, $this->childView);

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

        // explicitly call collectConfiguration(), since $this->childForm is not
        // contained in the form tree
        $this->dataCollector->collectConfiguration($this->form);
        $this->dataCollector->collectConfiguration($this->childForm);
        $this->dataCollector->buildFinalFormTree($this->form, $this->view);

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

        $formData = array(
            'config' => 'foo',
            'children' => array(
                'child' => $childFormData,
            ),
        );

        $this->assertSame(array(
            'forms' => array(
                'name' => $formData,
            ),
            'forms_by_hash' => array(
                spl_object_hash($this->form) => $formData,
                spl_object_hash($this->childForm) => $childFormData,
            ),
            'nb_errors' => 0,
        ), $this->dataCollector->getData());
    }