LiipFunctionalTestBundle
LiipFunctionalTestBundle copied to clipboard
What are the elements of the first argument passed to assertValidationErrors?
assertValidationErrors()
is supposed to get an array of fields as it's first argument, However it is not clear how those field are supposed to be identified. In the docs there is data.email
, now email
is the field name but what is data
? The Form Name?
I get very strange behaviour related to this, in a form containing both a threshold
field and name
field. threshold
is a number
field, and name
is a text
field. And both of them have only the NotBlank
Constraint. Now providing the following values:
$form['material[threshold]'] = '';
$form['material[name]'] = '';
The only way to get assertValidationErrors()
to pass is the following:
$this->assertValidationErrors(['children[threshold]', 'children[name].data'], $this->client->getContainer());
notice the .data
after children[name]
I don't remember why but the .data
has to been used during tests too: https://github.com/liip/LiipFunctionalTestBundle/blob/97cedfc1edd51e142044f2db3759bd96ef7a9d5a/Tests/Test/WebTestCaseTest.php#L541
If we look at the code called by the assertValidationErrors()
function, we can see that it mostly reuse Symfony components: https://github.com/liip/LiipFunctionalTestBundle/blob/97cedfc1edd51e142044f2db3759bd96ef7a9d5a/Test/ValidationErrorsConstraint.php https://github.com/liip/LiipFunctionalTestBundle/blob/e3ee7666c2a3fba5e4f1fd0c6887362d91bed889/Validator/DataCollectingValidator.php
And .data
is not explicitely defined in this Bundle.
So it looks like the .data
comes from Symfony's own code.