Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cea4155

Browse filesBrowse files
committed
[Validator] Fixed date-to-string conversion tests to match ICU 51
1 parent 5aa7e6d commit cea4155
Copy full SHA for cea4155

11 files changed

+38
-13
lines changed

‎src/Symfony/Component/Validator/ConstraintValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/ConstraintValidator.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,21 @@ protected function valueToString($value, $formatDates = false)
9696

9797
return (string) $value;
9898
}
99+
100+
/**
101+
* Returns a string representation of a list of values.
102+
*
103+
* @param array $values
104+
* @param Boolean $formatDates
105+
*
106+
* @return string
107+
*/
108+
protected function valuesToString(array $values, $formatDates = false)
109+
{
110+
foreach ($values as $key => $value) {
111+
$values[$key] = $this->valueToString($value, $formatDates);
112+
}
113+
114+
return implode(', ', $values);
115+
}
99116
}

‎src/Symfony/Component/Validator/Constraints/FileValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/FileValidator.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ public function validate($value, Constraint $constraint)
161161

162162
if (false === $valid) {
163163
$this->context->addViolation($constraint->mimeTypesMessage, array(
164-
'{{ type }}' => '"'.$mime.'"',
165-
'{{ types }}' => '"'.implode('", "', $mimeTypes) .'"',
164+
'{{ type }}' => $this->valueToString($mime),
165+
'{{ types }}' => $this->valuesToString($mimeTypes),
166166
'{{ file }}' => $path,
167167
));
168168
}

‎src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Component\Intl\Util\IntlTestHelper;
1415
use Symfony\Component\Validator\Constraint;
1516
use Symfony\Component\Validator\Constraints\AbstractComparisonValidator;
1617

@@ -73,12 +74,19 @@ abstract public function provideValidComparisons();
7374
/**
7475
* @dataProvider provideInvalidComparisons
7576
* @param mixed $dirtyValue
77+
* @param mixed $dirtyValueAsString
7678
* @param mixed $comparedValue
7779
* @param mixed $comparedValueString
7880
* @param string $comparedValueType
7981
*/
8082
public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType)
8183
{
84+
// Conversion of dates to string differs between ICU versions
85+
// Make sure we have the correct version loaded
86+
if ($dirtyValue instanceof \DateTime) {
87+
IntlTestHelper::requireIntl($this);
88+
}
89+
8290
$constraint = $this->createConstraint(array('value' => $comparedValue));
8391
$constraint->message = 'Constraint Message';
8492

‎src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function provideInvalidComparisons()
5151
return array(
5252
array(1, '1', 2, '2', 'integer'),
5353
array('22', '"22"', '333', '"333"', 'string'),
54-
array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime')
54+
array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime')
5555
);
5656
}
5757
}

‎src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function provideInvalidComparisons()
5252
{
5353
return array(
5454
array(1, '1', 2, '2', 'integer'),
55-
array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005 12:00 AM', 'DateTime'),
55+
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'),
5656
array('b', '"b"', 'c', '"c"', 'string')
5757
);
5858
}

‎src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function provideInvalidComparisons()
5050
return array(
5151
array(1, '1', 2, '2', 'integer'),
5252
array(2, '2', 2, '2', 'integer'),
53-
array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005 12:00 AM', 'DateTime'),
54-
array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', 'DateTime'),
53+
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'),
54+
array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
5555
array('22', '"22"', '333', '"333"', 'string'),
5656
array('22', '"22"', '22', '"22"', 'string')
5757
);

‎src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public function provideInvalidComparisons()
5353
array(1, '1', 2, '2', 'integer'),
5454
array(2, '2', '2', '"2"', 'string'),
5555
array('22', '"22"', '333', '"333"', 'string'),
56-
array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', 'DateTime'),
57-
array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999 12:00 AM', 'DateTime')
56+
array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', 'DateTime'),
57+
array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999, 12:00 AM', 'DateTime')
5858
);
5959
}
6060
}

‎src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function provideInvalidComparisons()
5252
{
5353
return array(
5454
array(2, '2', 1, '1', 'integer'),
55-
array(new \DateTime('2010-01-01'), 'Jan 1, 2010 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'),
55+
array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
5656
array('c', '"c"', 'b', '"b"', 'string')
5757
);
5858
}

‎src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function provideInvalidComparisons()
5050
return array(
5151
array(3, '3', 2, '2', 'integer'),
5252
array(2, '2', 2, '2', 'integer'),
53-
array(new \DateTime('2010-01-01'), 'Jan 1, 2010 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'),
54-
array(new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'),
53+
array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
54+
array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'),
5555
array('333', '"333"', '22', '"22"', 'string'),
5656
);
5757
}

‎src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function provideInvalidComparisons()
5151
array(3, '3', 3, '3', 'integer'),
5252
array('2', '"2"', 2, '2', 'integer'),
5353
array('a', '"a"', 'a', '"a"', 'string'),
54-
array(new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime')
54+
array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime')
5555
);
5656
}
5757
}

‎src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function provideInvalidComparisons()
5454
return array(
5555
array(3, '3', 3, '3', 'integer'),
5656
array('a', '"a"', 'a', '"a"', 'string'),
57-
array($date, 'Jan 1, 2000 12:00 AM', $date, 'Jan 1, 2000 12:00 AM', 'DateTime')
57+
array($date, 'Jan 1, 2000, 12:00 AM', $date, 'Jan 1, 2000, 12:00 AM', 'DateTime')
5858
);
5959
}
6060
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.