@@ -52,16 +52,19 @@ The simplest ``TypeTestCase`` implementation looks like the following::
5252 'test2' => 'test2',
5353 );
5454
55- $form = $this->factory->create(TestedType::class);
55+ $objectToCompare = new TestObject();
56+ // $objectToCompare will retrieve data from the form submission; pass it as the second argument
57+ $form = $this->factory->create(TestedType::class, $objectToCompare);
5658
5759 $object = new TestObject();
5860 // ...populate $object properties with the data stored in $formData
5961
6062 // submit the data to the form directly
6163 $form->submit($formData);
6264
65+ $objectToCompare = $form->getData();
6366 $this->assertTrue($form->isSynchronized());
64- $this->assertEquals($object, $form->getData() );
67+ $this->assertEquals($object, $objectToCompare );
6568
6669 $view = $form->createView();
6770 $children = $view->children;
@@ -78,7 +81,7 @@ First you verify if the ``FormType`` compiles. This includes basic class
7881inheritance, the ``buildForm() `` function and options resolution. This should
7982be the first test you write::
8083
81- $form = $this->factory->create(TestedType::class);
84+ $form = $this->factory->create(TestedType::class, $objectToCompare );
8285
8386This test checks that none of your data transformers used by the form
8487failed. The :method: `Symfony\\ Component\\ Form\\ FormInterface::isSynchronized `
@@ -96,7 +99,7 @@ method is only set to ``false`` if a data transformer throws an exception::
9699Next, verify the submission and mapping of the form. The test below
97100checks if all the fields are correctly specified::
98101
99- $this->assertEquals($object, $form->getData() );
102+ $this->assertEquals($object, $objectToCompare );
100103
101104Finally, check the creation of the ``FormView ``. You should check if all
102105widgets you want to display are available in the children property::
0 commit comments