@@ -52,17 +52,19 @@ The simplest ``TypeTestCase`` implementation looks like the following::
5252 'test2' => 'test2',
5353 );
5454
55- $type = new TestedType();
56- $form = $this->factory->create($type);
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);
5758
5859 $object = new TestObject();
5960 // ...populate $object properties with the data stored in $formData
6061
6162 // submit the data to the form directly
6263 $form->submit($formData);
6364
65+ $objectToCompare = $form->getData();
6466 $this->assertTrue($form->isSynchronized());
65- $this->assertEquals($object, $form->getData() );
67+ $this->assertEquals($object, $objectToCompare );
6668
6769 $view = $form->createView();
6870 $children = $view->children;
@@ -79,8 +81,7 @@ First you verify if the ``FormType`` compiles. This includes basic class
7981inheritance, the ``buildForm() `` function and options resolution. This should
8082be the first test you write::
8183
82- $type = new TestedType();
83- $form = $this->factory->create($type);
84+ $form = $this->factory->create(TestedType::class, $objectToCompare);
8485
8586This test checks that none of your data transformers used by the form
8687failed. The :method: `Symfony\\ Component\\ Form\\ FormInterface::isSynchronized `
@@ -98,7 +99,7 @@ method is only set to ``false`` if a data transformer throws an exception::
9899Next, verify the submission and mapping of the form. The test below
99100checks if all the fields are correctly specified::
100101
101- $this->assertEquals($object, $form->getData() );
102+ $this->assertEquals($object, $objectToCompare );
102103
103104Finally, check the creation of the ``FormView ``. You should check if all
104105widgets you want to display are available in the children property::
0 commit comments