Revert "bug #18935 [Form] Consider a violation even if the form is not submitted (egeloen)"
This reverts commitf28eb9a617
, reversing changes made tobbb75faa15
.
This commit is contained in:
parent
e4b48bbc88
commit
bcb1d8fd0c
@ -275,6 +275,9 @@ class ViolationMapper implements ViolationMapperInterface
|
|||||||
*/
|
*/
|
||||||
private function acceptsErrors(FormInterface $form)
|
private function acceptsErrors(FormInterface $form)
|
||||||
{
|
{
|
||||||
return $this->allowNonSynchronized || $form->isSynchronized();
|
// 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMappingIfNotSubmitted()
|
public function testAbortMappingIfNotSubmitted()
|
||||||
{
|
{
|
||||||
$violation = $this->getConstraintViolation('children[address].data.street');
|
$violation = $this->getConstraintViolation('children[address].data.street');
|
||||||
$parent = $this->getForm('parent');
|
$parent = $this->getForm('parent');
|
||||||
@ -230,12 +230,12 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->mapper->mapViolation($violation, $parent);
|
$this->mapper->mapViolation($violation, $parent);
|
||||||
|
|
||||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
|
$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');
|
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
|
||||||
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have one error');
|
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDotRuleMappingIfNotSubmitted()
|
public function testAbortDotRuleMappingIfNotSubmitted()
|
||||||
{
|
{
|
||||||
$violation = $this->getConstraintViolation('data.address');
|
$violation = $this->getConstraintViolation('data.address');
|
||||||
$parent = $this->getForm('parent');
|
$parent = $this->getForm('parent');
|
||||||
@ -255,9 +255,9 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->mapper->mapViolation($violation, $parent);
|
$this->mapper->mapViolation($violation, $parent);
|
||||||
|
|
||||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
|
$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');
|
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
|
||||||
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have an error');
|
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideDefaultTests()
|
public function provideDefaultTests()
|
||||||
|
Reference in New Issue
Block a user