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