Skip to content

Commit

Permalink
[Form] Consider a violation even if the form is not submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
GeLoLabs committed Jun 1, 2016
1 parent 00763f6 commit c483a0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ private function reconstructPath(ViolationPath $violationPath, FormInterface $or
*/
private function acceptsErrors(FormInterface $form)
{
// Ignore non-submitted forms. This happens, for example, in PATCH
// requests.
// https://github.com/symfony/symfony/pull/10567
return $form->isSubmitted() && ($this->allowNonSynchronized || $form->isSynchronized());
return $this->allowNonSynchronized || $form->isSynchronized();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function testAbortDotRuleMappingIfNotSynchronized()
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
}

public function testAbortMappingIfNotSubmitted()
public function testMappingIfNotSubmitted()
{
$violation = $this->getConstraintViolation('children[address].data.street');
$parent = $this->getForm('parent');
Expand All @@ -230,12 +230,12 @@ public function testAbortMappingIfNotSubmitted()

$this->mapper->mapViolation($violation, $parent);

$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error');
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have one error');
}

public function testAbortDotRuleMappingIfNotSubmitted()
public function testDotRuleMappingIfNotSubmitted()
{
$violation = $this->getConstraintViolation('data.address');
$parent = $this->getForm('parent');
Expand All @@ -255,9 +255,9 @@ public function testAbortDotRuleMappingIfNotSubmitted()

$this->mapper->mapViolation($violation, $parent);

$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error');
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have an error');
}

public function provideDefaultTests()
Expand Down

0 comments on commit c483a0f

Please sign in to comment.