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