@@ -47,16 +47,19 @@ The simplest ``TypeTestCase`` implementation looks like the following::
47
47
'test2' => 'test2',
48
48
);
49
49
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);
51
53
52
54
$object = new TestObject();
53
55
// ...populate $object properties with the data stored in $formData
54
56
55
57
// submit the data to the form directly
56
58
$form->submit($formData);
57
59
60
+ $objectToCompare = $form->getData();
58
61
$this->assertTrue($form->isSynchronized());
59
- $this->assertEquals($object, $form->getData() );
62
+ $this->assertEquals($object, $objectToCompare );
60
63
61
64
$view = $form->createView();
62
65
$children = $view->children;
@@ -73,7 +76,7 @@ First you verify if the ``FormType`` compiles. This includes basic class
73
76
inheritance, the ``buildForm() `` function and options resolution. This should
74
77
be the first test you write::
75
78
76
- $form = $this->factory->create(TestedType::class);
79
+ $form = $this->factory->create(TestedType::class, $objectToCompare );
77
80
78
81
This test checks that none of your data transformers used by the form
79
82
failed. The :method: `Symfony\\ Component\\ Form\\ FormInterface::isSynchronized `
@@ -91,7 +94,7 @@ method is only set to ``false`` if a data transformer throws an exception::
91
94
Next, verify the submission and mapping of the form. The test below
92
95
checks if all the fields are correctly specified::
93
96
94
- $this->assertEquals($object, $form->getData() );
97
+ $this->assertEquals($object, $objectToCompare );
95
98
96
99
Finally, check the creation of the ``FormView ``. You should check if all
97
100
widgets you want to display are available in the children property::
0 commit comments