8000 [Form] Fix constraints could be null if not set by DZunke · Pull Request #16897 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Form] Add test for non existing constraints option
  • Loading branch information
DZunke committed Dec 10, 2015
commit 54f527e82bdadaa13fff9dc13d7f0643d8a88eb3
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ public function testDontValidateIfParentWithoutCascadeValidation()
$this->assertNoViolation();
}

public function testNotExistingConstraintIndex()
Copy link
Contributor

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()?

{
$object = $this->getMock('\stdClass');
Copy link
Contributor

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?

Copy link
Contributor Author

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!

$options = array();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit creating this variable as FormBuilder's last parameter is array $options = array()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, Thanks.


$form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory, $options);
$form = $form->setData($object)->getForm();

$this->validator->validate($form, new Form());

$this->assertNoViolation();
}

public function testValidateConstraintsEvenIfNoCascadeValidation()
{
$object = $this->getMock('\stdClass');
Expand Down
0