|
26 | 26 | use Symfony\Component\Form\ResolvedFormType; |
27 | 27 | use Symfony\Component\Form\ResolvedFormTypeFactory; |
28 | 28 | use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; |
| 29 | +use Symfony\Component\Validator\Constraints\WordCount; |
29 | 30 | use Symfony\Component\Validator\ConstraintViolation; |
30 | 31 | use Symfony\Component\VarDumper\Test\VarDumperTestTrait; |
31 | 32 |
|
@@ -300,35 +301,68 @@ public function testExtractSubmittedDataStoresErrorCause() |
300 | 301 | $form->addError(new FormError('Invalid!', null, [], null, $violation)); |
301 | 302 | $origin = spl_object_hash($form); |
302 | 303 |
|
303 | | - $this->assertDumpMatchesFormat(<<<EODUMP |
304 | | -array:3 [ |
305 | | - "submitted_data" => array:1 [ |
306 | | - "norm" => "Foobar" |
307 | | - ] |
308 | | - "errors" => array:1 [ |
309 | | - 0 => array:3 [ |
310 | | - "message" => "Invalid!" |
311 | | - "origin" => "$origin" |
312 | | - "trace" => array:2 [ |
313 | | - 0 => Symfony\Component\Validator\ConstraintViolation { |
314 | | - -message: "Foo" |
315 | | - -messageTemplate: "Foo" |
316 | | - -parameters: [] |
317 | | - -plural: null |
318 | | - -root: "Root" |
319 | | - -propertyPath: "property.path" |
320 | | - -invalidValue: "Invalid!" |
321 | | - -constraint: null |
322 | | - -code: null |
323 | | - -cause: Exception {%A} |
| 304 | + if (class_exists(WordCount::class)) { |
| 305 | + $expectedFormat = <<<"EODUMP" |
| 306 | + array:3 [ |
| 307 | + "submitted_data" => array:1 [ |
| 308 | + "norm" => "Foobar" |
| 309 | + ] |
| 310 | + "errors" => array:1 [ |
| 311 | + 0 => array:3 [ |
| 312 | + "message" => "Invalid!" |
| 313 | + "origin" => "$origin" |
| 314 | + "trace" => array:2 [ |
| 315 | + 0 => Symfony\Component\Validator\ConstraintViolation { |
| 316 | + -message: "Foo" |
| 317 | + -messageTemplate: "Foo" |
| 318 | + -parameters: [] |
| 319 | + -root: "Root" |
| 320 | + -propertyPath: "property.path" |
| 321 | + -invalidValue: "Invalid!" |
| 322 | + -plural: null |
| 323 | + -code: null |
| 324 | + -constraint: null |
| 325 | + -cause: Exception {%A} |
| 326 | + } |
| 327 | + 1 => Exception {#1} |
| 328 | + ] |
| 329 | + ] |
| 330 | + ] |
| 331 | + "synchronized" => true |
| 332 | + ] |
| 333 | + EODUMP; |
| 334 | + } else { |
| 335 | + $expectedFormat = <<<"EODUMP" |
| 336 | + array:3 [ |
| 337 | + "submitted_data" => array:1 [ |
| 338 | + "norm" => "Foobar" |
| 339 | + ] |
| 340 | + "errors" => array:1 [ |
| 341 | + 0 => array:3 [ |
| 342 | + "message" => "Invalid!" |
| 343 | + "origin" => "$origin" |
| 344 | + "trace" => array:2 [ |
| 345 | + 0 => Symfony\Component\Validator\ConstraintViolation { |
| 346 | + -message: "Foo" |
| 347 | + -messageTemplate: "Foo" |
| 348 | + -parameters: [] |
| 349 | + -plural: null |
| 350 | + -root: "Root" |
| 351 | + -propertyPath: "property.path" |
| 352 | + -invalidValue: "Invalid!" |
| 353 | + -constraint: null |
| 354 | + -code: null |
| 355 | + -cause: Exception {%A} |
| 356 | + } |
| 357 | + 1 => Exception {#1} |
| 358 | + ] |
| 359 | + ] |
| 360 | + ] |
| 361 | + "synchronized" => true |
| 362 | + ] |
| 363 | + EODUMP; |
324 | 364 | } |
325 | | - 1 => Exception {#1} |
326 | | - ] |
327 | | - ] |
328 | | - ] |
329 | | - "synchronized" => true |
330 | | -] |
331 | | -EODUMP |
| 365 | + $this->assertDumpMatchesFormat($expectedFormat |
332 | 366 | , |
333 | 367 | $this->dataExtractor->extractSubmittedData($form) |
334 | 368 | ); |
|
0 commit comments