From 3b1e83380b927017e6e9d2a8d88d67e78343c0ae Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Sep 2010 07:59:45 +0200 Subject: [PATCH] [Validator] removed the convention that error parameters are delimited with %% --- .../Validator/ConstraintViolation.php | 9 +------ .../Constraints/AssertTypeValidator.php | 4 +-- .../Validator/Constraints/BlankValidator.php | 2 +- .../Validator/Constraints/ChoiceValidator.php | 8 +++--- .../Constraints/CollectionValidator.php | 4 +-- .../Constraints/DateTimeValidator.php | 2 +- .../Validator/Constraints/DateValidator.php | 2 +- .../Validator/Constraints/EmailValidator.php | 4 +-- .../Validator/Constraints/FileValidator.php | 16 ++++++------ .../Constraints/MaxLengthValidator.php | 4 +-- .../Validator/Constraints/MaxValidator.php | 4 +-- .../Constraints/MinLengthValidator.php | 4 +-- .../Validator/Constraints/MinValidator.php | 4 +-- .../Validator/Constraints/NullValidator.php | 2 +- .../Validator/Constraints/RegexValidator.php | 2 +- .../Validator/Constraints/TimeValidator.php | 2 +- .../Validator/Constraints/UrlValidator.php | 2 +- .../Validator/Constraints/ValidValidator.php | 2 +- .../Constraints/AssertTypeValidatorTest.php | 4 +-- .../Constraints/BlankValidatorTest.php | 2 +- .../Constraints/ChoiceValidatorTest.php | 8 +++--- .../Constraints/DateTimeValidatorTest.php | 2 +- .../Constraints/DateValidatorTest.php | 2 +- .../Constraints/EmailValidatorTest.php | 2 +- .../Constraints/FileValidatorTest.php | 26 +++++++++---------- .../Constraints/MaxLengthValidatorTest.php | 4 +-- .../Constraints/MaxValidatorTest.php | 4 +-- .../Constraints/MinLengthValidatorTest.php | 4 +-- .../Constraints/MinValidatorTest.php | 4 +-- .../Constraints/NullValidatorTest.php | 2 +- .../Constraints/RegexValidatorTest.php | 2 +- .../Constraints/TimeValidatorTest.php | 2 +- .../Constraints/UrlValidatorTest.php | 2 +- 33 files changed, 70 insertions(+), 77 deletions(-) diff --git a/src/Symfony/Component/Validator/ConstraintViolation.php b/src/Symfony/Component/Validator/ConstraintViolation.php index 161c389e73..e66e614a98 100644 --- a/src/Symfony/Component/Validator/ConstraintViolation.php +++ b/src/Symfony/Component/Validator/ConstraintViolation.php @@ -31,14 +31,7 @@ class ConstraintViolation public function getMessage() { - $sources = array(); - $targets = array(); - foreach ($this->messageParameters as $key => $value) { - $sources[] = '{{ '.$key.' }}'; - $targets[] = (string) $value; - } - - return str_replace($sources, $targets, $this->messageTemplate); + return str_replace(array_keys($sources), array_values($targets), $this->messageTemplate); } public function getRoot() diff --git a/src/Symfony/Component/Validator/Constraints/AssertTypeValidator.php b/src/Symfony/Component/Validator/Constraints/AssertTypeValidator.php index d2d1f359b2..f490521f76 100644 --- a/src/Symfony/Component/Validator/Constraints/AssertTypeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AssertTypeValidator.php @@ -23,8 +23,8 @@ class AssertTypeValidator extends ConstraintValidator } $this->setMessage($constraint->message, array( - 'value' => $value, - 'type' => $constraint->type, + '{{ value }}' => $value, + '{{ type }}' => $constraint->type, )); return false; diff --git a/src/Symfony/Component/Validator/Constraints/BlankValidator.php b/src/Symfony/Component/Validator/Constraints/BlankValidator.php index 89f0abec6c..2826ea54e3 100644 --- a/src/Symfony/Component/Validator/Constraints/BlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BlankValidator.php @@ -10,7 +10,7 @@ class BlankValidator extends ConstraintValidator public function isValid($value, Constraint $constraint) { if ($value !== '' && $value !== null) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index b935173f4d..016c4c524a 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -53,7 +53,7 @@ class ChoiceValidator extends ConstraintValidator if ($constraint->multiple) { foreach ($value as $_value) { if (!in_array($_value, $choices, true)) { - $this->setMessage($constraint->message, array('value' => $_value)); + $this->setMessage($constraint->message, array('{{ value }}' => $_value)); return false; } @@ -62,18 +62,18 @@ class ChoiceValidator extends ConstraintValidator $count = count($value); if ($constraint->min !== null && $count < $constraint->min) { - $this->setMessage($constraint->minMessage, array('limit' => $constraint->min)); + $this->setMessage($constraint->minMessage, array('{{ limit }}' => $constraint->min)); return false; } if ($constraint->max !== null && $count > $constraint->max) { - $this->setMessage($constraint->maxMessage, array('limit' => $constraint->max)); + $this->setMessage($constraint->maxMessage, array('{{ limit }}' => $constraint->max)); return false; } } elseif (!in_array($value, $choices, true)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php index 422add362c..cf0d181dd4 100644 --- a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -48,7 +48,7 @@ class CollectionValidator extends ConstraintValidator if (count($extraFields) > 0 && !$constraint->allowExtraFields) { $this->setMessage($constraint->extraFieldsMessage, array( - 'fields' => '"'.implode('", "', array_keys($extraFields)).'"' + '{{ fields }}' => '"'.implode('", "', array_keys($extraFields)).'"' )); return false; @@ -56,7 +56,7 @@ class CollectionValidator extends ConstraintValidator if (count($missingFields) > 0 && !$constraint->allowMissingFields) { $this->setMessage($constraint->missingFieldsMessage, array( - 'fields' => '"'.implode('", "', $missingFields).'"' + '{{ fields }}' => '"'.implode('", "', $missingFields).'"' )); return false; diff --git a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php index 506e61b0eb..5c153dbc8c 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php @@ -27,7 +27,7 @@ class DateTimeValidator extends ConstraintValidator $value = (string)$value; if (!preg_match(self::PATTERN, $value, $matches)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/DateValidator.php b/src/Symfony/Component/Validator/Constraints/DateValidator.php index f4ab56aa31..dc2a830a45 100644 --- a/src/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateValidator.php @@ -23,7 +23,7 @@ class DateValidator extends ConstraintValidator $value = (string)$value; if (!preg_match(self::PATTERN, $value, $matches)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index 11df24817c..c697200708 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -23,7 +23,7 @@ class EmailValidator extends ConstraintValidator $value = (string)$value; if (!preg_match(self::PATTERN, $value)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } @@ -32,7 +32,7 @@ class EmailValidator extends ConstraintValidator $host = substr($value, strpos($value, '@') + 1); if (!$this->checkMX($host)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index a741560279..6edf514aec 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -27,13 +27,13 @@ class FileValidator extends ConstraintValidator $path = $value instanceof FileObject ? $value->getPath() : (string)$value; if (!file_exists($path)) { - $this->setMessage($constraint->notFoundMessage, array('file' => $path)); + $this->setMessage($constraint->notFoundMessage, array('{{ file }}' => $path)); return false; } if (!is_readable($path)) { - $this->setMessage($constraint->notReadableMessage, array('file' => $path)); + $this->setMessage($constraint->notReadableMessage, array('{{ file }}' => $path)); return false; } @@ -57,9 +57,9 @@ class FileValidator extends ConstraintValidator if ($size > $limit) { $this->setMessage($constraint->maxSizeMessage, array( - 'size' => $size . $suffix, - 'limit' => $limit . $suffix, - 'file' => $path, + '{{ size }}' => $size . $suffix, + '{{ limit }}' => $limit . $suffix, + '{{ file }}' => $path, )); return false; @@ -73,9 +73,9 @@ class FileValidator extends ConstraintValidator if (!in_array($value->getMimeType(), (array)$constraint->mimeTypes)) { $this->setMessage($constraint->mimeTypesMessage, array( - 'type' => '"'.$value->getMimeType().'"', - 'types' => '"'.implode('", "', (array)$constraint->mimeTypes).'"', - 'file' => $path, + '{{ type }}' => '"'.$value->getMimeType().'"', + '{{ types }}' => '"'.implode('", "', (array)$constraint->mimeTypes).'"', + '{{ file }}' => $path, )); return false; diff --git a/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php b/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php index cd69b0dd3d..19b3d8486d 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php @@ -24,8 +24,8 @@ class MaxLengthValidator extends ConstraintValidator if ($length > $constraint->limit) { $this->setMessage($constraint->message, array( - 'value' => $value, - 'limit' => $constraint->limit, + '{{ value }}' => $value, + '{{ limit }}' => $constraint->limit, )); return false; diff --git a/src/Symfony/Component/Validator/Constraints/MaxValidator.php b/src/Symfony/Component/Validator/Constraints/MaxValidator.php index 654eef4ef7..3f7bb25755 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MaxValidator.php @@ -20,8 +20,8 @@ class MaxValidator extends ConstraintValidator if ($value > $constraint->limit) { $this->setMessage($constraint->message, array( - 'value' => $value, - 'limit' => $constraint->limit, + '{{ value }}' => $value, + '{{ limit }}' => $constraint->limit, )); return false; diff --git a/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php b/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php index 93a75d4e69..bfc55475b7 100644 --- a/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php @@ -24,8 +24,8 @@ class MinLengthValidator extends ConstraintValidator if ($length < $constraint->limit) { $this->setMessage($constraint->message, array( - 'value' => $value, - 'limit' => $constraint->limit, + '{{ value }}' => $value, + '{{ limit }}' => $constraint->limit, )); return false; diff --git a/src/Symfony/Component/Validator/Constraints/MinValidator.php b/src/Symfony/Component/Validator/Constraints/MinValidator.php index 146ab8dab0..73925470a9 100644 --- a/src/Symfony/Component/Validator/Constraints/MinValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MinValidator.php @@ -20,8 +20,8 @@ class MinValidator extends ConstraintValidator if ($value < $constraint->limit) { $this->setMessage($constraint->message, array( - 'value' => $value, - 'limit' => $constraint->limit, + '{{ value }}' => $value, + '{{ limit }}' => $constraint->limit, )); return false; diff --git a/src/Symfony/Component/Validator/Constraints/NullValidator.php b/src/Symfony/Component/Validator/Constraints/NullValidator.php index a3f51d16f3..265e1f4367 100644 --- a/src/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NullValidator.php @@ -10,7 +10,7 @@ class NullValidator extends ConstraintValidator public function isValid($value, Constraint $constraint) { if (!is_null($value)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/RegexValidator.php b/src/Symfony/Component/Validator/Constraints/RegexValidator.php index 9418762e38..a04beb7fa1 100644 --- a/src/Symfony/Component/Validator/Constraints/RegexValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RegexValidator.php @@ -26,7 +26,7 @@ class RegexValidator extends ConstraintValidator (!$constraint->match && preg_match($constraint->pattern, $value)) ) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php index 6f1b281953..96c6faf6ee 100644 --- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -23,7 +23,7 @@ class TimeValidator extends ConstraintValidator $value = (string)$value; if (!preg_match(self::PATTERN, $value)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index 353c7692b7..151df2e85f 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -34,7 +34,7 @@ class UrlValidator extends ConstraintValidator $pattern = sprintf(self::PATTERN, implode('|', $constraint->protocols)); if (!preg_match($pattern, $value)) { - $this->setMessage($constraint->message, array('value' => $value)); + $this->setMessage($constraint->message, array('{{ value }}' => $value)); return false; } diff --git a/src/Symfony/Component/Validator/Constraints/ValidValidator.php b/src/Symfony/Component/Validator/Constraints/ValidValidator.php index 5ff281f354..286d774e7e 100644 --- a/src/Symfony/Component/Validator/Constraints/ValidValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ValidValidator.php @@ -27,7 +27,7 @@ class ValidValidator extends ConstraintValidator } else if (!is_object($value)) { throw new UnexpectedTypeException($value, 'object or array'); } else if ($constraint->class && !$value instanceof $constraint->class) { - $this->setMessage($constraint->message, array('class' => $constraint->class)); + $this->setMessage($constraint->message, array('{{ class }}' => $constraint->class)); return false; } else { diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/AssertTypeValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/AssertTypeValidatorTest.php index 26c7892d8f..5bd57bd26e 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/AssertTypeValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/AssertTypeValidatorTest.php @@ -101,8 +101,8 @@ class AssertTypeValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', - 'type' => 'numeric', + '{{ value }}' => 'foobar', + '{{ type }}' => 'numeric', )); } diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/BlankValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/BlankValidatorTest.php index 8b30a09915..d14fa6f57f 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/BlankValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/BlankValidatorTest.php @@ -51,7 +51,7 @@ class BlankValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', + '{{ value }}' => 'foobar', )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php index fd1b95946d..256133ae07 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php @@ -118,7 +118,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('baz', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'baz', + '{{ value }}' => 'baz', )); } @@ -133,7 +133,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid(array('foo', 'baz'), $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'baz', + '{{ value }}' => 'baz', )); } @@ -149,7 +149,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid(array('foo'), $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'limit' => 2, + '{{ limit }}' => 2, )); } @@ -165,7 +165,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid(array('foo', 'bar', 'moo'), $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'limit' => 2, + '{{ limit }}' => 2, )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/DateTimeValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/DateTimeValidatorTest.php index 3e1b537d4d..b3232e1c6a 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/DateTimeValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/DateTimeValidatorTest.php @@ -76,7 +76,7 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', + '{{ value }}' => 'foobar', )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/DateValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/DateValidatorTest.php index e8af2b3982..a3e2dcae89 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/DateValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/DateValidatorTest.php @@ -70,7 +70,7 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', + '{{ value }}' => 'foobar', )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/EmailValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/EmailValidatorTest.php index b742bc9395..ba7b13db9e 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/EmailValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/EmailValidatorTest.php @@ -70,7 +70,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', + '{{ value }}' => 'foobar', )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/FileValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/FileValidatorTest.php index fc9950aa6b..bebb21024d 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/FileValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/FileValidatorTest.php @@ -52,9 +52,9 @@ class FileValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid($this->path, $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'limit' => '10 bytes', - 'size' => '11 bytes', - 'file' => $this->path, + '{{ limit }}' => '10 bytes', + '{{ size }}' => '11 bytes', + '{{ file }}' => $this->path, )); } @@ -70,9 +70,9 @@ class FileValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid($this->path, $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'limit' => '1 kB', - 'size' => '1.4 kB', - 'file' => $this->path, + '{{ limit }}' => '1 kB', + '{{ size }}' => '1.4 kB', + '{{ file }}' => $this->path, )); } @@ -88,9 +88,9 @@ class FileValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid($this->path, $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'limit' => '1 MB', - 'size' => '1.4 MB', - 'file' => $this->path, + '{{ limit }}' => '1 MB', + '{{ size }}' => '1.4 MB', + '{{ file }}' => $this->path, )); } @@ -114,7 +114,7 @@ class FileValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'file' => 'foobar', + '{{ file }}' => 'foobar', )); } @@ -153,9 +153,9 @@ class FileValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid($file, $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'type' => '"application/pdf"', - 'types' => '"image/png", "image/jpg"', - 'file' => $this->path, + '{{ type }}' => '"application/pdf"', + '{{ types }}' => '"image/png", "image/jpg"', + '{{ file }}' => $this->path, )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/MaxLengthValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/MaxLengthValidatorTest.php index 5f0c0e387c..5c7d366915 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/MaxLengthValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/MaxLengthValidatorTest.php @@ -78,8 +78,8 @@ class MaxLengthValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('123456', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => '123456', - 'limit' => 5, + '{{ value }}' => '123456', + '{{ limit }}' => 5, )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/MaxValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/MaxValidatorTest.php index 0a36629589..d2787b2ca4 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/MaxValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/MaxValidatorTest.php @@ -72,8 +72,8 @@ class MaxValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid(11, $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 11, - 'limit' => 10, + '{{ value }}' => 11, + '{{ limit }}' => 10, )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/MinLengthValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/MinLengthValidatorTest.php index ec1b43097d..5fc4cd78e0 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/MinLengthValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/MinLengthValidatorTest.php @@ -78,8 +78,8 @@ class MinLengthValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('1234', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => '1234', - 'limit' => 5, + '{{ value }}' => '1234', + '{{ limit }}' => 5, )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/MinValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/MinValidatorTest.php index 29700648e9..46e0d1dd6e 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/MinValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/MinValidatorTest.php @@ -72,8 +72,8 @@ class MinValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid(9, $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 9, - 'limit' => 10, + '{{ value }}' => 9, + '{{ limit }}' => 10, )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/NullValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/NullValidatorTest.php index f373f0947e..59a5f856e4 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/NullValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/NullValidatorTest.php @@ -46,7 +46,7 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid(1, $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 1, + '{{ value }}' => 1, )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/RegexValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/RegexValidatorTest.php index b30016bcd3..dced91a227 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/RegexValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/RegexValidatorTest.php @@ -72,7 +72,7 @@ class RegexValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', + '{{ value }}' => 'foobar', )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/TimeValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/TimeValidatorTest.php index 9dbc865236..79234823e9 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/TimeValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/TimeValidatorTest.php @@ -71,7 +71,7 @@ class TimeValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', + '{{ value }}' => 'foobar', )); } } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/UrlValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/UrlValidatorTest.php index 2952249db4..588d08587a 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/UrlValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/UrlValidatorTest.php @@ -74,7 +74,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->validator->isValid('foobar', $constraint)); $this->assertEquals($this->validator->getMessageTemplate(), 'myMessage'); $this->assertEquals($this->validator->getMessageParameters(), array( - 'value' => 'foobar', + '{{ value }}' => 'foobar', )); } } \ No newline at end of file