@@ -47,16 +47,19 @@ The simplest ``TypeTestCase`` implementation looks like the following::
4747 'test2' => 'test2',
4848 );
4949
50- $form = $this->factory->create(TestedType::class);
50+ $objectToCompare = new TestObject();
51+ // $objectToCompare will retrieve data from the form submission; pass it as the second argument
52+ $form = $this->factory->create(TestedType::class, $objectToCompare);
5153
5254 $object = new TestObject();
5355 // ...populate $object properties with the data stored in $formData
5456
5557 // submit the data to the form directly
5658 $form->submit($formData);
5759
60+ $objectToCompare = $form->getData();
5861 $this->assertTrue($form->isSynchronized());
59- $this->assertEquals($object, $form->getData() );
62+ $this->assertEquals($object, $objectToCompare );
6063
6164 $view = $form->createView();
6265 $children = $view->children;
@@ -73,7 +76,7 @@ First you verify if the ``FormType`` compiles. This includes basic class
7376inheritance, the ``buildForm() `` function and options resolution. This should
7477be the first test you write::
7578
76- $form = $this->factory->create(TestedType::class);
79+ $form = $this->factory->create(TestedType::class, $objectToCompare );
7780
7881This test checks that none of your data transformers used by the form
7982failed. The :method: `Symfony\\ Component\\ Form\\ FormInterface::isSynchronized `
@@ -91,7 +94,7 @@ method is only set to ``false`` if a data transformer throws an exception::
9194Next, verify the submission and mapping of the form. The test below
9295checks if all the fields are correctly specified::
9396
94- $this->assertEquals($object, $form->getData() );
97+ $this->assertEquals($object, $objectToCompare );
9598
9699Finally, check the creation of the ``FormView ``. You should check if all
97100widgets you want to display are available in the children property::
0 commit comments