Skip to content

Commit

Permalink
minor #35207 [Form] ensure to expect no validation for the right reas…
Browse files Browse the repository at this point in the history
…ons (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] ensure to expect no validation for the right reasons

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

8d46f95 ensure to expect no validation for the right reasons
  • Loading branch information
nicolas-grekas committed Jan 4, 2020
2 parents 51d8070 + 8d46f95 commit 9392f76
Showing 1 changed file with 25 additions and 0 deletions.
Expand Up @@ -133,7 +133,10 @@ public function testDontValidateIfParentWithoutValidConstraint()
$parent->add($form);

$form->setData($object);
$parent->submit([]);

$this->assertTrue($form->isSubmitted());
$this->assertTrue($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand Down Expand Up @@ -188,10 +191,15 @@ public function testDontValidateIfNoValidationGroups()
'validation_groups' => [],
])
->setData($object)
->setCompound(true)
->setDataMapper(new PropertyPathMapper())
->getForm();

$form->setData($object);
$form->submit([]);

$this->assertTrue($form->isSubmitted());
$this->assertTrue($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand All @@ -214,6 +222,8 @@ public function testDontValidateConstraintsIfNoValidationGroups()
// Launch transformer
$form->submit('foo');

$this->assertTrue($form->isSubmitted());
$this->assertTrue($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand All @@ -236,6 +246,8 @@ public function testDontValidateChildConstraintsIfCallableNoValidationGroups()
$form->add($child);
$form->submit([]);

$this->assertTrue($form->isSubmitted());
$this->assertTrue($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand Down Expand Up @@ -264,6 +276,8 @@ function () { throw new TransformationFailedException(); }
// Launch transformer
$form->submit('foo');

$this->assertTrue($form->isSubmitted());
$this->assertFalse($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand Down Expand Up @@ -299,6 +313,8 @@ function () { throw new TransformationFailedException(); }
// Launch transformer
$form->submit('foo');

$this->assertTrue($form->isSubmitted());
$this->assertFalse($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand Down Expand Up @@ -369,6 +385,8 @@ function () { throw new TransformationFailedException(); }
// Launch transformer
$form->submit(['child' => 'foo']);

$this->assertTrue($form->isSubmitted());
$this->assertFalse($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand Down Expand Up @@ -574,7 +592,10 @@ public function testDontWalkScalars()
$form = $this->getBuilder()
->setData('scalar')
->getForm();
$form->submit('foo');

$this->assertTrue($form->isSubmitted());
$this->assertTrue($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand All @@ -592,6 +613,8 @@ public function testViolationIfExtraData()

$form->submit(['foo' => 'bar']);

$this->assertTrue($form->isSubmitted());
$this->assertTrue($form->isSynchronized());
$this->expectNoValidate();

$this->validator->validate($form, new Form());
Expand All @@ -613,6 +636,8 @@ public function testViolationFormatIfMultipleExtraFields()

$form->submit(['foo' => 'bar', 'baz' => 'qux', 'quux' => 'quuz']);

$this->assertTrue($form->isSubmitted());
$this->assertTrue($form->isSynchronized());
$this->expectNoValidate();

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

0 comments on commit 9392f76

Please sign in to comment.