@@ -125,6 +125,8 @@ public function testMapToFormInheritingParentDataIfDataDoesNotMatch()
125
125
$ parent ->add ($ child );
126
126
$ child ->add ($ grandChild );
127
127
128
+ $ parent ->submit (array ());
129
+
128
130
$ this ->mapper ->mapViolation ($ violation , $ parent );
129
131
130
132
$ this ->assertCount (0 , $ parent ->getErrors (), $ parent ->getName ().' should not have an error, but has one ' );
@@ -150,6 +152,8 @@ public function testFollowDotRules()
150
152
$ child ->add ($ grandChild );
151
153
$ grandChild ->add ($ grandGrandChild );
152
154
155
+ $ parent ->submit (array ());
156
+
153
157
$ this ->mapper ->mapViolation ($ violation , $ parent );
154
158
155
159
$ this ->assertCount (0 , $ parent ->getErrors (), $ parent ->getName ().' should not have an error, but has one ' );
@@ -170,7 +174,7 @@ public function testAbortMappingIfNotSynchronized()
170
174
$ parent ->add ($ child );
171
175
$ child ->add ($ grandChild );
172
176
173
- // submit to invoke the transformer and mark the form unsynchronized
177
+ // invoke the transformer and mark the form unsynchronized
174
178
$ parent ->submit (array ());
175
179
176
180
$ this ->mapper ->mapViolation ($ violation , $ parent );
@@ -194,7 +198,7 @@ public function testAbortDotRuleMappingIfNotSynchronized()
194
198
$ parent ->add ($ child );
195
199
$ child ->add ($ grandChild );
196
200
197
- // submit to invoke the transformer and mark the form unsynchronized
201
+ // invoke the transformer and mark the form unsynchronized
198
202
$ parent ->submit (array ());
199
203
200
204
$ this ->mapper ->mapViolation ($ violation , $ parent );
@@ -204,6 +208,54 @@ public function testAbortDotRuleMappingIfNotSynchronized()
204
208
$ this ->assertCount (0 , $ grandChild ->getErrors (), $ grandChild ->getName ().' should not have an error, but has one ' );
205
209
}
206
210
211
+ public function testAbortMappingIfNotSubmitted ()
212
+ {
213
+ $ violation = $ this ->getConstraintViolation ('children[address].data.street ' );
214
+ $ parent = $ this ->getForm ('parent ' );
215
+ $ child = $ this ->getForm ('address ' , 'address ' );
216
+ $ grandChild = $ this ->getForm ('street ' , 'street ' );
217
+
218
+ $ parent ->add ($ child );
219
+ $ child ->add ($ grandChild );
220
+
221
+ // Disable automatic submission of missing fields
222
+ $ parent ->submit (array (), false );
223
+ $ child ->submit (array (), false );
224
+
225
+ // $grandChild is not submitted
226
+
227
+ $ this ->mapper ->mapViolation ($ violation , $ parent );
228
+
229
+ $ this ->assertCount (0 , $ parent ->getErrors (), $ parent ->getName ().' should not have an error, but has one ' );
230
+ $ this ->assertCount (0 , $ child ->getErrors (), $ child ->getName ().' should not have an error, but has one ' );
231
+ $ this ->assertCount (0 , $ grandChild ->getErrors (), $ grandChild ->getName ().' should not have an error, but has one ' );
232
+ }
233
+
234
+ public function testAbortDotRuleMappingIfNotSubmitted ()
235
+ {
236
+ $ violation = $ this ->getConstraintViolation ('data.address ' );
237
+ $ parent = $ this ->getForm ('parent ' );
238
+ $ child = $ this ->getForm ('address ' , 'address ' , null , array (
239
+ '. ' => 'street ' ,
240
+ ));
241
+ $ grandChild = $ this ->getForm ('street ' );
242
+
243
+ $ parent ->add ($ child );
244
+ $ child ->add ($ grandChild );
245
+
246
+ // Disable automatic submission of missing fields
247
+ $ parent ->submit (array (), false );
248
+ $ child ->submit (array (), false );
249
+
250
+ // $grandChild is not submitted
251
+
252
+ $ this ->mapper ->mapViolation ($ violation , $ parent );
253
+
254
+ $ this ->assertCount (0 , $ parent ->getErrors (), $ parent ->getName ().' should not have an error, but has one ' );
255
+ $ this ->assertCount (0 , $ child ->getErrors (), $ child ->getName ().' should not have an error, but has one ' );
256
+ $ this ->assertCount (0 , $ grandChild ->getErrors (), $ grandChild ->getName ().' should not have an error, but has one ' );
257
+ }
258
+
207
259
public function provideDefaultTests ()
208
260
{
209
261
// The mapping must be deterministic! If a child has the property path "[street]",
@@ -743,6 +795,8 @@ public function testDefaultErrorMapping($target, $childName, $childPath, $grandC
743
795
$ parent ->add ($ child );
744
796
$ child ->add ($ grandChild );
745
797
798
+ $ parent ->submit (array ());
799
+
746
800
$ this ->mapper ->mapViolation ($ violation , $ parent );
747
801
748
802
if (self ::LEVEL_0 === $ target ) {
@@ -1211,6 +1265,8 @@ public function testCustomDataErrorMapping($target, $mapFrom, $mapTo, $childName
1211
1265
$ parent ->add ($ distraction );
1212
1266
}
1213
1267
1268
+ $ parent ->submit (array ());
1269
+
1214
1270
$ this ->mapper ->mapViolation ($ violation , $ parent );
1215
1271
1216
1272
if ($ target !== self ::LEVEL_0 ) {
@@ -1396,6 +1452,8 @@ public function testCustomFormErrorMapping($target, $mapFrom, $mapTo, $errorName
1396
1452
$ parent ->add ($ errorChild );
1397
1453
$ child ->add ($ grandChild );
1398
1454
1455
+ $ parent ->submit (array ());
1456
+
1399
1457
$ this ->mapper ->mapViolation ($ violation , $ parent );
1400
1458
1401
1459
if (self ::LEVEL_0 === $ target ) {
@@ -1459,6 +1517,8 @@ public function testErrorMappingForFormInheritingParentData($target, $childName,
1459
1517
$ parent ->add ($ child );
1460
1518
$ child ->add ($ grandChild );
1461
1519
1520
+ $ parent ->submit (array ());
1521
+
1462
1522
$ this ->mapper ->mapViolation ($ violation , $ parent );
1463
1523
1464
1524
if (self ::LEVEL_0 === $ target ) {
0 commit comments