Skip to content

Commit 5a58305

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (36 commits) [Debug] fix error message on double exception [Validator] make DateTime objects represented as strings in the violation message. [RFC] [DebugBundle] [HttpKernel] Avoid using container as dependency for DumpListener Upgrade information for the Translation component regarding the new LoggingTranslator class. [WebProfilerBundle] Remove usage of app.request in search bar template Fix initialized() with aliased services fix data type in docblock Rename Symfony2 to Symfony bumped Symfony version to 2.6.0 updated VERSION for 2.6.0-BETA2 updated CHANGELOG for 2.6.0-BETA2 [Debug] fix ENT_SUBSTITUTE usage compare version using PHP_VERSION_ID backport #12489 remove an unneeded check Remove block submit_widget reformat code as suggested by @fabpot Fix typo Make `\Request::get` more performant. properly set request attributes in controller test ...
2 parents 94dd963 + cbf6575 commit 5a58305

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

Constraints/RangeValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function validate($value, Constraint $constraint)
3535

3636
if (!is_numeric($value) && !$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
3737
$this->buildViolation($constraint->invalidMessage)
38-
->setParameter('{{ value }}', $this->formatValue($value))
38+
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
3939
->setCode(Range::INVALID_VALUE_ERROR)
4040
->addViolation();
4141

@@ -61,7 +61,7 @@ public function validate($value, Constraint $constraint)
6161

6262
if (null !== $constraint->max && $value > $max) {
6363
$this->buildViolation($constraint->maxMessage)
64-
->setParameter('{{ value }}', $value)
64+
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
6565
->setParameter('{{ limit }}', $this->formatValue($max, self::PRETTY_DATE))
6666
->setCode(Range::BEYOND_RANGE_ERROR)
6767
->addViolation();
@@ -71,7 +71,7 @@ public function validate($value, Constraint $constraint)
7171

7272
if (null !== $constraint->min && $value < $min) {
7373
$this->buildViolation($constraint->minMessage)
74-
->setParameter('{{ value }}', $value)
74+
->setParameter('{{ value }}', $this->formatValue($value, self::PRETTY_DATE))
7575
->setParameter('{{ limit }}', $this->formatValue($min, self::PRETTY_DATE))
7676
->setCode(Range::BELOW_RANGE_ERROR)
7777
->addViolation();

Tests/Constraints/RangeValidatorTest.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ public function getTenToTwenty()
5252
public function getLessThanTen()
5353
{
5454
return array(
55-
array(9.99999),
56-
array('9.99999'),
57-
array(5),
58-
array(1.0),
55+
array(9.99999, '9.99999'),
56+
array('9.99999', '"9.99999"'),
57+
array(5, '5'),
58+
array(1.0, '1.0'),
5959
);
6060
}
6161

6262
public function getMoreThanTwenty()
6363
{
6464
return array(
65-
array(20.000001),
66-
array('20.000001'),
67-
array(21),
68-
array(30.0),
65+
array(20.000001, '20.000001'),
66+
array('20.000001', '"20.000001"'),
67+
array(21, '21'),
68+
array(30.0, '30.0'),
6969
);
7070
}
7171

@@ -105,7 +105,7 @@ public function testValidValuesMinMax($value)
105105
/**
106106
* @dataProvider getLessThanTen
107107
*/
108-
public function testInvalidValuesMin($value)
108+
public function testInvalidValuesMin($value, $formattedValue)
109109
{
110110
$constraint = new Range(array(
111111
'min' => 10,
@@ -115,7 +115,7 @@ public function testInvalidValuesMin($value)
115115
$this->validator->validate($value, $constraint);
116116

117117
$this->buildViolation('myMessage')
118-
->setParameter('{{ value }}', $value)
118+
->setParameter('{{ value }}', $formattedValue)
119119
->setParameter('{{ limit }}', 10)
120120
->setCode(Range::BELOW_RANGE_ERROR)
121121
->assertRaised();
@@ -124,7 +124,7 @@ public function testInvalidValuesMin($value)
124124
/**
125125
* @dataProvider getMoreThanTwenty
126126
*/
127-
public function testInvalidValuesMax($value)
127+
public function testInvalidValuesMax($value, $formattedValue)
128128
{
129129
$constraint = new Range(array(
130130
'max' => 20,
@@ -134,7 +134,7 @@ public function testInvalidValuesMax($value)
134134
$this->validator->validate($value, $constraint);
135135

136136
$this->buildViolation('myMessage')
137-
->setParameter('{{ value }}', $value)
137+
->setParameter('{{ value }}', $formattedValue)
138138
->setParameter('{{ limit }}', 20)
139139
->setCode(Range::BEYOND_RANGE_ERROR)
140140
->assertRaised();
@@ -143,7 +143,7 @@ public function testInvalidValuesMax($value)
143143
/**
144144
* @dataProvider getMoreThanTwenty
145145
*/
146-
public function testInvalidValuesCombinedMax($value)
146+
public function testInvalidValuesCombinedMax($value, $formattedValue)
147147
{
148148
$constraint = new Range(array(
149149
'min' => 10,
@@ -155,7 +155,7 @@ public function testInvalidValuesCombinedMax($value)
155155
$this->validator->validate($value, $constraint);
156156

157157
$this->buildViolation('myMaxMessage')
158-
->setParameter('{{ value }}', $value)
158+
->setParameter('{{ value }}', $formattedValue)
159159
->setParameter('{{ limit }}', 20)
160160
->setCode(Range::BEYOND_RANGE_ERROR)
161161
->assertRaised();
@@ -164,7 +164,7 @@ public function testInvalidValuesCombinedMax($value)
164164
/**
165165
* @dataProvider getLessThanTen
166166
*/
167-
public function testInvalidValuesCombinedMin($value)
167+
public function testInvalidValuesCombinedMin($value, $formattedValue)
168168
{
169169
$constraint = new Range(array(
170170
'min' => 10,
@@ -176,7 +176,7 @@ public function testInvalidValuesCombinedMin($value)
176176
$this->validator->validate($value, $constraint);
177177

178178
$this->buildViolation('myMinMessage')
179-
->setParameter('{{ value }}', $value)
179+
->setParameter('{{ value }}', $formattedValue)
180180
->setParameter('{{ limit }}', 10)
181181
->setCode(Range::BELOW_RANGE_ERROR)
182182
->assertRaised();
@@ -212,13 +212,13 @@ public function getSoonerThanTenthMarch2014()
212212
$this->setDefaultTimezone('UTC');
213213

214214
$tests = array(
215-
array(new \DateTime('March 20, 2013')),
216-
array(new \DateTime('March 9, 2014')),
215+
array(new \DateTime('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'),
216+
array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'),
217217
);
218218

219219
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
220-
$tests[] = array(new \DateTimeImmutable('March 20, 2013'));
221-
$tests[] = array(new \DateTimeImmutable('March 9, 2014'));
220+
$tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM');
221+
$tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM');
222222
}
223223

224224
$this->restoreDefaultTimezone();
@@ -233,13 +233,13 @@ public function getLaterThanTwentiethMarch2014()
233233
$this->setDefaultTimezone('UTC');
234234

235235
$tests = array(
236-
array(new \DateTime('March 21, 2014')),
237-
array(new \DateTime('March 9, 2015')),
236+
array(new \DateTime('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'),
237+
array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'),
238238
);
239239

240240
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
241-
$tests[] = array(new \DateTimeImmutable('March 21, 2014'));
242-
$tests[] = array(new \DateTimeImmutable('March 9, 2015'));
241+
$tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM');
242+
$tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM');
243243
}
244244

245245
$this->restoreDefaultTimezone();
@@ -283,7 +283,7 @@ public function testValidDatesMinMax($value)
283283
/**
284284
* @dataProvider getSoonerThanTenthMarch2014
285285
*/
286-
public function testInvalidDatesMin($value)
286+
public function testInvalidDatesMin($value, $dateTimeAsString)
287287
{
288288
// Conversion of dates to string differs between ICU versions
289289
// Make sure we have the correct version loaded
@@ -297,7 +297,7 @@ public function testInvalidDatesMin($value)
297297
$this->validator->validate($value, $constraint);
298298

299299
$this->buildViolation('myMessage')
300-
->setParameter('{{ value }}', $value)
300+
->setParameter('{{ value }}', $dateTimeAsString)
301301
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
302302
->setCode(Range::BELOW_RANGE_ERROR)
303303
->assertRaised();
@@ -306,7 +306,7 @@ public function testInvalidDatesMin($value)
306306
/**
307307
* @dataProvider getLaterThanTwentiethMarch2014
308308
*/
309-
public function testInvalidDatesMax($value)
309+
public function testInvalidDatesMax($value, $dateTimeAsString)
310310
{
311311
// Conversion of dates to string differs between ICU versions
312312
// Make sure we have the correct version loaded
@@ -320,7 +320,7 @@ public function testInvalidDatesMax($value)
320320
$this->validator->validate($value, $constraint);
321321

322322
$this->buildViolation('myMessage')
323-
->setParameter('{{ value }}', $value)
323+
->setParameter('{{ value }}', $dateTimeAsString)
324324
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
325325
->setCode(Range::BEYOND_RANGE_ERROR)
326326
->assertRaised();
@@ -329,7 +329,7 @@ public function testInvalidDatesMax($value)
329329
/**
330330
* @dataProvider getLaterThanTwentiethMarch2014
331331
*/
332-
public function testInvalidDatesCombinedMax($value)
332+
public function testInvalidDatesCombinedMax($value, $dateTimeAsString)
333333
{
334334
// Conversion of dates to string differs between ICU versions
335335
// Make sure we have the correct version loaded
@@ -345,7 +345,7 @@ public function testInvalidDatesCombinedMax($value)
345345
$this->validator->validate($value, $constraint);
346346

347347
$this->buildViolation('myMaxMessage')
348-
->setParameter('{{ value }}', $value)
348+
->setParameter('{{ value }}', $dateTimeAsString)
349349
->setParameter('{{ limit }}', 'Mar 20, 2014, 12:00 AM')
350350
->setCode(Range::BEYOND_RANGE_ERROR)
351351
->assertRaised();
@@ -354,7 +354,7 @@ public function testInvalidDatesCombinedMax($value)
354354
/**
355355
* @dataProvider getSoonerThanTenthMarch2014
356356
*/
357-
public function testInvalidDatesCombinedMin($value)
357+
public function testInvalidDatesCombinedMin($value, $dateTimeAsString)
358358
{
359359
// Conversion of dates to string differs between ICU versions
360360
// Make sure we have the correct version loaded
@@ -370,7 +370,7 @@ public function testInvalidDatesCombinedMin($value)
370370
$this->validator->validate($value, $constraint);
371371

372372
$this->buildViolation('myMinMessage')
373-
->setParameter('{{ value }}', $value)
373+
->setParameter('{{ value }}', $dateTimeAsString)
374374
->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')
375375
->setCode(Range::BELOW_RANGE_ERROR)
376376
->assertRaised();

Tests/Validator/LegacyValidator2Dot5ApiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
2121
{
2222
protected function setUp()
2323
{
24-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
24+
if (PHP_VERSION_ID < 50309) {
2525
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
2626
}
2727

Tests/Validator/LegacyValidatorLegacyApiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest
2121
{
2222
protected function setUp()
2323
{
24-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
24+
if (PHP_VERSION_ID < 50309) {
2525
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
2626
}
2727

Tests/ValidatorBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testSetTranslationDomain()
112112

113113
public function testDefaultApiVersion()
114114
{
115-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
115+
if (PHP_VERSION_ID < 50309) {
116116
// Old implementation on PHP < 5.3.9
117117
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
118118
} else {
@@ -135,7 +135,7 @@ public function testSetApiVersion25()
135135

136136
public function testSetApiVersion24And25()
137137
{
138-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
138+
if (PHP_VERSION_ID < 50309) {
139139
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
140140
}
141141

ValidatorBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public function setApiVersion($apiVersion)
325325
));
326326
}
327327

328-
if (version_compare(PHP_VERSION, '5.3.9', '<') && $apiVersion === Validation::API_VERSION_2_5_BC) {
328+
if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) {
329329
throw new InvalidArgumentException(sprintf(
330330
'The Validator API that is compatible with both Symfony 2.4 '.
331331
'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '.
@@ -385,7 +385,7 @@ public function getValidator()
385385
$apiVersion = $this->apiVersion;
386386

387387
if (null === $apiVersion) {
388-
$apiVersion = version_compare(PHP_VERSION, '5.3.9', '<')
388+
$apiVersion = PHP_VERSION_ID < 50309
389389
? Validation::API_VERSION_2_4
390390
: Validation::API_VERSION_2_5_BC;
391391
}

0 commit comments

Comments
 (0)