Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  fix tests
  • Loading branch information
xabbuh committed Jul 19, 2024
2 parents 1d0128e + 67dd6a3 commit 2713488
Showing 1 changed file with 62 additions and 28 deletions.
90 changes: 62 additions & 28 deletions Tests/Extension/DataCollector/FormDataExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Symfony\Component\Form\ResolvedFormType;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
use Symfony\Component\Validator\Constraints\WordCount;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;

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

$this->assertDumpMatchesFormat(<<<EODUMP
array:3 [
"submitted_data" => array:1 [
"norm" => "Foobar"
]
"errors" => array:1 [
0 => array:3 [
"message" => "Invalid!"
"origin" => "$origin"
"trace" => array:2 [
0 => Symfony\Component\Validator\ConstraintViolation {
-message: "Foo"
-messageTemplate: "Foo"
-parameters: []
-plural: null
-root: "Root"
-propertyPath: "property.path"
-invalidValue: "Invalid!"
-constraint: null
-code: null
-cause: Exception {%A}
if (class_exists(WordCount::class)) {
$expectedFormat = <<<"EODUMP"
array:3 [
"submitted_data" => array:1 [
"norm" => "Foobar"
]
"errors" => array:1 [
0 => array:3 [
"message" => "Invalid!"
"origin" => "$origin"
"trace" => array:2 [
0 => Symfony\Component\Validator\ConstraintViolation {
-message: "Foo"
-messageTemplate: "Foo"
-parameters: []
-root: "Root"
-propertyPath: "property.path"
-invalidValue: "Invalid!"
-plural: null
-code: null
-constraint: null
-cause: Exception {%A}
}
1 => Exception {#1}
]
]
]
"synchronized" => true
]
EODUMP;
} else {
$expectedFormat = <<<"EODUMP"
array:3 [
"submitted_data" => array:1 [
"norm" => "Foobar"
]
"errors" => array:1 [
0 => array:3 [
"message" => "Invalid!"
"origin" => "$origin"
"trace" => array:2 [
0 => Symfony\Component\Validator\ConstraintViolation {
-message: "Foo"
-messageTemplate: "Foo"
-parameters: []
-plural: null
-root: "Root"
-propertyPath: "property.path"
-invalidValue: "Invalid!"
-constraint: null
-code: null
-cause: Exception {%A}
}
1 => Exception {#1}
]
]
]
"synchronized" => true
]
EODUMP;
}
1 => Exception {#1}
]
]
]
"synchronized" => true
]
EODUMP
$this->assertDumpMatchesFormat($expectedFormat
,
$this->dataExtractor->extractSubmittedData($form)
);
Expand Down

0 comments on commit 2713488

Please sign in to comment.