-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Fix constraints could be null if not set #16897
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
Conversation
If the form options has no key for constraints the default should be an empty array to be ignored by the loop.
Can you add a test case please? |
@jakzal hope the test is ok. needed to get my own FormBuilder Instance cause the default "getBuilder" method used by all other tests has default options including the constraints index. |
@@ -123,6 +123,19 @@ public function testDontValidateIfParentWithoutCascadeValidation() | |||
$this->assertNoViolation(); | |||
} | |||
|
|||
public function testNotExistingConstraintIndex() | |||
{ | |||
$object = $this->getMock('\stdClass'); |
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.
Can you see any advantage of creating a dummy double for stdClass rather than simply creating the object?
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.
Nope. I'd only copied cause of the lack of knowledge in writing tests. Thanks for the Hint!
@@ -123,6 +123,17 @@ public function testDontValidateIfParentWithoutCascadeValidation() | |||
$this->assertNoViolation(); | |||
} | |||
|
|||
public function testNotExistingConstraintIndex() |
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.
Can we call it testMissingConstraintIndex()
?
Thank you @DZunke. |
This PR was squashed before being merged into the 2.3 branch (closes #16897). Discussion ---------- [Form] Fix constraints could be null if not set | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - If the form options has no key for constraints the default should be an empty array to be ignored by the loop in the FormValidator. The default without this fix is ```null``` and foreach will throw an error. The "Bug" also still exists in master-Branch. Commits ------- f80e0eb [Form] Fix constraints could be null if not set
If the form options has no key for constraints the default should be an empty array to be ignored by the loop in the FormValidator. The default without this fix is
null
and foreach will throw an error.The "Bug" also still exists in master-Branch.