Skip to content

Commit 67dd6a3

Browse files
committed
fix tests
1 parent 196ebc7 commit 67dd6a3

File tree

1 file changed

+62
-28
lines changed

1 file changed

+62
-28
lines changed

Tests/Extension/DataCollector/FormDataExtractorTest.php

+62-28
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Symfony\Component\Form\ResolvedFormType;
2727
use Symfony\Component\Form\ResolvedFormTypeFactory;
2828
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
29+
use Symfony\Component\Validator\Constraints\WordCount;
2930
use Symfony\Component\Validator\ConstraintViolation;
3031
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
3132

@@ -300,35 +301,68 @@ public function testExtractSubmittedDataStoresErrorCause()
300301
$form->addError(new FormError('Invalid!', null, [], null, $violation));
301302
$origin = spl_object_hash($form);
302303

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;
324364
}
325-
1 => Exception {#1}
326-
]
327-
]
328-
]
329-
"synchronized" => true
330-
]
331-
EODUMP
365+
$this->assertDumpMatchesFormat($expectedFormat
332366
,
333367
$this->dataExtractor->extractSubmittedData($form)
334368
);

0 commit comments

Comments
 (0)