New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Form] FormValidator removed code related to removed cascade_validation
option
#18081
Conversation
peterrehm
commented
Mar 9, 2016
Q | A |
---|---|
Branch | 3.0 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #18063 |
License | MIT |
Args, should be merged into 3.0. |
I see some tests are failing, but only with some deps versions. Does anyone have a hint in this regards? |
I would rename:
and |
Updated, just the PHP 7 test with the low deps fails, is this maybe due to subtree split or so? |
@@ -149,11 +127,11 @@ public function testValidateIfChildWithValidConstraint() | |||
$this->assertNoViolation(); | |||
} | |||
|
|||
public function testDontValidateIfParentWithoutCascadeValidation() | |||
public function testDontValidateIfParentWithoutValidConstraint() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need these tests? Don't they duplicate other tests here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, I thought it might be intended as it looks like the test for an explizit cascade without the option/constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd appreciate if you could check the other test cases whether any of them duplicates this one. If that's the case, we can safely remove this. This was mainly designed in order to test the special treatment of the cascade_validation
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding it looks like it is not duplicated as we have the related tests
- testValidateConstraintsEvenIfNoValidConstraint
- testValidateIfChildWithValidConstraint
- testDontValidateIfParentWithoutValidConstraint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me phrase this another way: Is there any way to make these two tests fail (individually) without making at least one other test in this test class fail at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems so, but I am actually a bit confused about the difference of testValidateConstraintsEvenIfNoValidConstraint
and testDontValidateIfParentWithoutValidConstraint
as it looks like in the first tests constraints in the child are validated even when there is no Valid constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterrehm I guess the naming of the tests is confusing. We have two different cases:
- the
constraints
option: Constraints set in this option are always validated (given their groups match). - the
Valid
constraint: This constraint (either set in the validation metadata - e.g. as annotation - or in theconstraints
option) results in the constraints defined ine the metadata of the data being validated.
Example:
// data_class = Customer
$form->add('address', FormType::class);
$form->get('address')->add('street', TextType::class, [
'constraints' => new NotBlank(),
]);
class Customer
{
private $address;
}
class Address
{
/**
* @Length(min=3)
*/
private $street;
}
In this example, by default only the NotBlank
constraint is validated. The constraints defined in the Address
class, however, are not validated:
- There is no
Valid
constraint in theconstraints
option of theaddress
field in the form. - There is no
Valid
constraint on theCustomer::$address
property.
If you add the Valid
constraint in either of these places, the Length
constraint is validated as well.
We could clarify the tests for example by renaming testValidateConstraintsEvenIfNoValidConstraint
to testValidateConstraintsOptionEvenIfParentWithoutValidConstraint
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better! Could you name the three tests for the Valid constraint consistently?
- testValidateChildIfValidConstraint
- testDontValidateChildIfNoValidConstraint
- testValidateConstraintsOptionEvenIfNoValidConstraint
Any further feedback? |
👍 to be merged in 3.0 Status: Reviewed |
After re-reading the tests I came to the following conclusions:
EDIT: Added byFormConstraints into the new test names as there is a difference between validating form data by constraints defined in form and constraints defined on the class of the form data object. |
@webmozart Updated. |
👍 apart from my last remark |
@webmozart: Updated, I hope it is as per your request. |
Looks like you need to fix the tests:
|
Updated. |
Thank you @peterrehm. |
…ade_validation` option (peterrehm) This PR was submitted for the master branch but it was merged into the 3.0 branch instead (closes #18081). Discussion ---------- [Form] FormValidator removed code related to removed `cascade_validation` option | Q | A | ------------- | --- | Branch | 3.0 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18063 | License | MIT Commits ------- 05fe6f9 [Form] FormValidator removed code related to removed option