Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
@@ -372,6 +372,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
->getForm();
$this->expectValidateAt(0, 'data', $object, new GroupSequence(array('group1', 'group2')));
$this->expectValidateAt(1, 'data', $object, new GroupSequence(array('group1', 'group2')));
$this->validator->validate($form, new Form());
@@ -12,21 +12,29 @@
namespace Symfony\Component\Form\Tests\Extension\Validator\Type;
use Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Forms;
use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest;
use Symfony\Component\Form\Tests\Extension\Core\Type\TextTypeTest;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Validation;
class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
{
public function testSubmitValidatesData()
{
$builder = $this->factory->createBuilder(
'Symfony\Component\Form\Extension\Core\Type\FormType',
FormTypeTest::TESTED_TYPE,
null,
array(
'validation_groups' => 'group',
)
);
$builder->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\FormType');
$builder->add('firstName', FormTypeTest::TESTED_TYPE);
$form = $builder->getForm();
$this->validator->expects($this->once())
@@ -53,8 +61,27 @@ class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
$this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension);
}
public function testGroupSequenceWithConstraintsOption()
{
$form = Forms::createFormFactoryBuilder()
->addExtension(new ValidatorExtension(Validation::createValidator()))
->getFormFactory()
->create(FormTypeTest::TESTED_TYPE, null, (array('validation_groups' => new GroupSequence(array('First', 'Second')))))
->add('field', TextTypeTest::TESTED_TYPE, array(
'constraints' => array(
new Length(array('min' => 10, 'groups' => array('First'))),
new Email(array('groups' => array('Second'))),
),
))
;
$form->submit(array('field' => 'wrong'));
$this->assertCount(1, $form->getErrors(true));
}
protected function createForm(array $options = array())
{
return $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, $options);
return $this->factory->create(FormTypeTest::TESTED_TYPE, null, $options);
}
}
@@ -29,11 +29,8 @@ use Symfony\Component\Validator\ConstraintViolationInterface;
class ViolationMapperTest extends TestCase
{
const LEVEL_0 = 0;
const LEVEL_1 = 1;
const LEVEL_1B = 2;
const LEVEL_2 = 3;
/**
@@ -1260,7 +1257,7 @@ class ViolationMapperTest extends TestCase
// Only add it if we expect the error to come up on a different
// level than LEVEL_0, because in this case the error would
// (correctly) be mapped to the distraction field
if ($target !== self::LEVEL_0) {
if (self::LEVEL_0 !== $target) {
$mapFromPath = new PropertyPath($mapFrom);
$mapFromPrefix = $mapFromPath->isIndex(0)
? '['.$mapFromPath->getElement(0).']'
@@ -1274,7 +1271,7 @@ class ViolationMapperTest extends TestCase
$this->mapper->mapViolation($violation, $parent);
if ($target !== self::LEVEL_0) {
if (self::LEVEL_0 !== $target) {
$this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one');
}
@@ -96,7 +96,7 @@ class ViolationPathTest extends TestCase
$path = new ViolationPath($string);
$this->assertSame($slicedPath, $path->__toString());
$this->assertSame(count($entries), count($path->getElements()));
$this->assertCount(count($entries), $path->getElements());
$this->assertSame(count($entries), $path->getLength());
foreach ($entries as $index => $entry) {