Skip to content

Commit 6c01962

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Misspelled word Display a better error design when the toolbar cannot be displayed do not validate empty values [Console] fix description of INF default values [PropertyAccess] Fix TypeError discard [Validator] Throw exception on Comparison constraints null options Identify tty tests in Component/Process [Security] Fix annotation
2 parents 9f323f7 + 9a1d6f9 commit 6c01962

12 files changed

+29
-18
lines changed

Constraints/AbstractComparison.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ abstract class AbstractComparison extends Constraint
3030
*/
3131
public function __construct($options = null)
3232
{
33+
if (null === $options) {
34+
$options = array();
35+
}
36+
3337
if (is_array($options) && !isset($options['value'])) {
3438
throw new ConstraintDefinitionException(sprintf(
3539
'The %s constraint requires the "value" option to be set.',

Constraints/UrlValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function validate($value, Constraint $constraint)
4848
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Url');
4949
}
5050

51-
if (null === $value) {
51+
if (null === $value || '' === $value) {
5252
return;
5353
}
5454

Resources/translations/validators.fr.xlf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@
7676
</trans-unit>
7777
<trans-unit id="19">
7878
<source>This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.</source>
79-
<target>Cette chaine est trop longue. Elle doit avoir au maximum {{ limit }} caractère.|Cette chaine est trop longue. Elle doit avoir au maximum {{ limit }} caractères.</target>
79+
<target>Cette chaîne est trop longue. Elle doit avoir au maximum {{ limit }} caractère.|Cette chaîne est trop longue. Elle doit avoir au maximum {{ limit }} caractères.</target>
8080
</trans-unit>
8181
<trans-unit id="20">
8282
<source>This value should be {{ limit }} or more.</source>
8383
<target>Cette valeur doit être supérieure ou égale à {{ limit }}.</target>
8484
</trans-unit>
8585
<trans-unit id="21">
8686
<source>This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.</source>
87-
<target>Cette chaine est trop courte. Elle doit avoir au minimum {{ limit }} caractère.|Cette chaine est trop courte. Elle doit avoir au minimum {{ limit }} caractères.</target>
87+
<target>Cette chaîne est trop courte. Elle doit avoir au minimum {{ limit }} caractère.|Cette chaîne est trop courte. Elle doit avoir au minimum {{ limit }} caractères.</target>
8888
</trans-unit>
8989
<trans-unit id="22">
9090
<source>This value should not be blank.</source>
@@ -180,7 +180,7 @@
180180
</trans-unit>
181181
<trans-unit id="48">
182182
<source>This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.</source>
183-
<target>Cette chaine doit avoir exactement {{ limit }} caractère.|Cette chaine doit avoir exactement {{ limit }} caractères.</target>
183+
<target>Cette chaîne doit avoir exactement {{ limit }} caractère.|Cette chaîne doit avoir exactement {{ limit }} caractères.</target>
184184
</trans-unit>
185185
<trans-unit id="49">
186186
<source>The file was only partially uploaded.</source>

Tests/Constraints/AbstractComparisonValidatorTestCase.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,21 @@ protected static function addPhp5Dot5Comparisons(array $comparisons)
6868
return $result;
6969
}
7070

71+
public function provideInvalidConstraintOptions()
72+
{
73+
return array(
74+
array(null),
75+
array(array()),
76+
);
77+
}
78+
7179
/**
80+
* @dataProvider provideInvalidConstraintOptions
7281
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
7382
*/
74-
public function testThrowsConstraintExceptionIfNoValueOrProperty()
83+
public function testThrowsConstraintExceptionIfNoValueOrProperty($options)
7584
{
76-
$comparison = $this->createConstraint(array());
77-
78-
$this->validator->validate('some value', $comparison);
85+
$this->createConstraint($options);
7986
}
8087

8188
/**
@@ -170,11 +177,11 @@ public function provideAllInvalidComparisons()
170177
abstract public function provideInvalidComparisons();
171178

172179
/**
173-
* @param array $options Options for the constraint
180+
* @param array|null $options Options for the constraint
174181
*
175182
* @return Constraint
176183
*/
177-
abstract protected function createConstraint(array $options);
184+
abstract protected function createConstraint(array $options = null);
178185

179186
/**
180187
* @return string|null

Tests/Constraints/EqualToValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new EqualToValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new EqualTo($options);
3636
}

Tests/Constraints/GreaterThanOrEqualValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new GreaterThanOrEqualValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new GreaterThanOrEqual($options);
3636
}

Tests/Constraints/GreaterThanValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new GreaterThanValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new GreaterThan($options);
3636
}

Tests/Constraints/IdenticalToValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new IdenticalToValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new IdenticalTo($options);
3636
}

Tests/Constraints/LessThanOrEqualValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new LessThanOrEqualValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new LessThanOrEqual($options);
3636
}

Tests/Constraints/LessThanValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new LessThanValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new LessThan($options);
3636
}

Tests/Constraints/NotEqualToValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new NotEqualToValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new NotEqualTo($options);
3636
}

Tests/Constraints/NotIdenticalToValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function createValidator()
3030
return new NotIdenticalToValidator();
3131
}
3232

33-
protected function createConstraint(array $options)
33+
protected function createConstraint(array $options = null)
3434
{
3535
return new NotIdenticalTo($options);
3636
}

0 commit comments

Comments
 (0)