composer update
This commit is contained in:
parent
f6abc3dce2
commit
71dfaca858
1753 changed files with 45274 additions and 14619 deletions
|
@ -53,4 +53,59 @@ EOF;
|
|||
|
||||
$this->assertSame($expected, (string) $violation);
|
||||
}
|
||||
|
||||
public function testToStringHandlesCodes()
|
||||
{
|
||||
$violation = new ConstraintViolation(
|
||||
'42 cannot be used here',
|
||||
'this is the message template',
|
||||
array(),
|
||||
array('some_value' => 42),
|
||||
'some_value',
|
||||
null,
|
||||
null,
|
||||
0
|
||||
);
|
||||
|
||||
$expected = <<<'EOF'
|
||||
Array.some_value:
|
||||
42 cannot be used here (code 0)
|
||||
EOF;
|
||||
|
||||
$this->assertSame($expected, (string) $violation);
|
||||
}
|
||||
|
||||
public function testToStringOmitsEmptyCodes()
|
||||
{
|
||||
$expected = <<<'EOF'
|
||||
Array.some_value:
|
||||
42 cannot be used here
|
||||
EOF;
|
||||
|
||||
$violation = new ConstraintViolation(
|
||||
'42 cannot be used here',
|
||||
'this is the message template',
|
||||
array(),
|
||||
array('some_value' => 42),
|
||||
'some_value',
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
$this->assertSame($expected, (string) $violation);
|
||||
|
||||
$violation = new ConstraintViolation(
|
||||
'42 cannot be used here',
|
||||
'this is the message template',
|
||||
array(),
|
||||
array('some_value' => 42),
|
||||
'some_value',
|
||||
null,
|
||||
null,
|
||||
''
|
||||
);
|
||||
|
||||
$this->assertSame($expected, (string) $violation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ class IbanValidatorTest extends ConstraintValidatorTestCase
|
|||
array('TR330006100519786457841326'), //Turkey
|
||||
array('UA213223130000026007233566001'), //Ukraine
|
||||
array('AE260211000000230064016'), //United Arab Emirates
|
||||
array('VA59001123000012345678'), //Vatican City State
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -274,6 +275,7 @@ class IbanValidatorTest extends ConstraintValidatorTestCase
|
|||
array('TR3300061005197864578413261'), //Turkey
|
||||
array('UA21AAAA1300000260072335660012'), //Ukraine
|
||||
array('AE2602110000002300640161'), //United Arab Emirates
|
||||
array('VA590011230000123456781'), //Vatican City State
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -385,6 +387,7 @@ class IbanValidatorTest extends ConstraintValidatorTestCase
|
|||
array('TR330006100519786457841327'), //Turkey
|
||||
array('UA213223130000026007233566002'), //Ukraine
|
||||
array('AE260211000000230064017'), //United Arab Emirates
|
||||
array('VA59001123000012345671'), //Vatican City State
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
namespace Symfony\Component\Validator\Tests\Validator;
|
||||
|
||||
use Symfony\Component\Translation\IdentityTranslator;
|
||||
use Symfony\Component\Validator\Constraints\All;
|
||||
use Symfony\Component\Validator\Constraints\Collection;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\ConstraintValidatorFactory;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextFactory;
|
||||
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
|
||||
|
@ -95,4 +99,38 @@ class RecursiveValidatorTest extends AbstractTest
|
|||
|
||||
$validator->validate($entity, null, array());
|
||||
}
|
||||
|
||||
public function testCollectionConstraintValidateAllGroupsForNestedConstraints()
|
||||
{
|
||||
$this->metadata->addPropertyConstraint('data', new Collection(array('fields' => array(
|
||||
'one' => array(new NotBlank(array('groups' => 'one')), new Length(array('min' => 2, 'groups' => 'two'))),
|
||||
'two' => array(new NotBlank(array('groups' => 'two'))),
|
||||
))));
|
||||
|
||||
$entity = new Entity();
|
||||
$entity->data = array('one' => 't', 'two' => '');
|
||||
|
||||
$violations = $this->validator->validate($entity, null, array('one', 'two'));
|
||||
|
||||
$this->assertCount(2, $violations);
|
||||
$this->assertInstanceOf(Length::class, $violations->get(0)->getConstraint());
|
||||
$this->assertInstanceOf(NotBlank::class, $violations->get(1)->getConstraint());
|
||||
}
|
||||
|
||||
public function testAllConstraintValidateAllGroupsForNestedConstraints()
|
||||
{
|
||||
$this->metadata->addPropertyConstraint('data', new All(array('constraints' => array(
|
||||
new NotBlank(array('groups' => 'one')),
|
||||
new Length(array('min' => 2, 'groups' => 'two')),
|
||||
))));
|
||||
|
||||
$entity = new Entity();
|
||||
$entity->data = array('one' => 't', 'two' => '');
|
||||
|
||||
$violations = $this->validator->validate($entity, null, array('one', 'two'));
|
||||
|
||||
$this->assertCount(2, $violations);
|
||||
$this->assertInstanceOf(NotBlank::class, $violations->get(0)->getConstraint());
|
||||
$this->assertInstanceOf(Length::class, $violations->get(1)->getConstraint());
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue